redis新增集群节点-redis集群管理

2016-07-21|来源:

新增一个节点6383,并启动


执行redis-trib.rb add-node命令添加节点

redis-trib.rb add-node  new_host:new_port existing_host:existing_port
[root@master redis-cluster]# /opt/redis/redis-3.2.1/src/redis-trib.rb add-node 192.168.56.101:6383 192.168.56.101:6380
>>> Adding node 192.168.56.101:6383 to cluster 192.168.56.101:6380
>>> Performing Cluster Check (using node 192.168.56.101:6380)
M: ecaef90fb93d61edd7522221136be88ae66ad3bc 192.168.56.101:6380
   slots:0-5460 (5461 slots) master
   0 additional replica(s)
M: 52953677dbc82dc4f17b33a922b38462944b002c 192.168.56.101:6382
   slots:10923-16383 (5461 slots) master
   0 additional replica(s)
M: c6e6b65324fac0711a22439d264cca141d2e5082 192.168.56.101:6381
   slots:5461-10922 (5462 slots) master
   0 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Send CLUSTER MEET to node 192.168.56.101:6383 to make it join the cluster.
[OK] New node added correctly.


查看集群信息:

192.168.56.101:6382> cluster nodes
03596d92625f1b778f29eb4a9128d92809dfd79a 192.168.56.101:6381 master - 0 1468853934619 2 connected 5461-10922
e6d316a0dcd7cfcc98de645d86989d5527e86e55 192.168.56.101:6383 master - 0 1468853932181 0 connected
b1939026deb80fedde7bdb22c1df3ecfaa72f608 192.168.56.101:6380 master - 0 1468853933604 1 connected 0-5460
6aa027917d223b8fedd42893a89fb0e2c07c8b27 192.168.56.101:6382 myself,master - 0 0 3 connected 10923-16383


发现刚添加进来的6383没有插槽数,接下来给新添加的6383分配插槽,将集群中的一部分(1000个)插槽分配给6383

[root@master redis-cluster]# /opt/redis/redis-3.2.1/src/redis-trib.rb reshard 192.168.56.101:6380
>>> Performing Cluster Check (using node 192.168.56.101:6380)
M: b1939026deb80fedde7bdb22c1df3ecfaa72f608 192.168.56.101:6380
   slots:0-5460 (5461 slots) master
   0 additional replica(s)
M: 6aa027917d223b8fedd42893a89fb0e2c07c8b27 192.168.56.101:6382
   slots:10923-16383 (5461 slots) master
   0 additional replica(s)
M: 03596d92625f1b778f29eb4a9128d92809dfd79a 192.168.56.101:6381
   slots:5461-10922 (5462 slots) master
   0 additional replica(s)
M: e6d316a0dcd7cfcc98de645d86989d5527e86e55 192.168.56.101:6383
   slots: (0 slots) master
   0 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)? 1000【要移动的插槽数】
What is the receiving node ID? e6d316a0dcd7cfcc98de645d86989d5527e86e55【接收节点】
Please enter all the source node IDs.
  Type 'all' to use all the nodes as source nodes for the hash slots.【所有的节点重新分配插槽】
  Type 'done' once you entered all the source nodes IDs.【数据要提到slot的节点ID,最后用done结束】
Source node #1:all
......
Do you want to proceed with the proposed reshard plan (yes/no)? yes
......





重新查看集群节点信息

192.168.56.101:6382> cluster nodes
03596d92625f1b778f29eb4a9128d92809dfd79a 192.168.56.101:6381 master - 0 1468855258984 2 connected 5795-10922
e6d316a0dcd7cfcc98de645d86989d5527e86e55 192.168.56.101:6383 master - 0 1468855261016 4 connected 0-332 5461-5794 10923-11255
b1939026deb80fedde7bdb22c1df3ecfaa72f608 192.168.56.101:6380 master - 0 1468855260001 1 connected 333-5460
6aa027917d223b8fedd42893a89fb0e2c07c8b27 192.168.56.101:6382 myself,master - 0 0 3 connected 11256-16383


书生参考网络整理


相关问答

更多

redis怎么设置节点为集群节点

将src下的可执行命令全部移动到/usr/local/redis/bin/目录下,执行该命令:mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server /usr/local/redis/bin,然后将配置文件移动到/usr/local/redis/etc/目录下,执行该命令:mv redis.conf /usr/local/redis/etc/。 ...

使用spring-data-redis集群redis,

用的是什么集群方式,JedisSentinelPool 还是ShardedJedisPool。 如果用的是前者,配置是需要连接sentinel端口的(默认26379),不是连接redis端口(6379)。 或者把spring相关配置文件贴出来一下。 <!-- 分片式redis集群配置 --> <bean id="jedisShardInfo1" class="redis.clients.jedis.JedisShardInfo"> <constructor-arg name="host" valu ...

使用spring-data-redis集群redis,

用的是什么集群方式,JedisSentinelPool 还是ShardedJedisPool。 如果用的是前者,配置是需要连接sentinel端口的(默认26379),不是连接redis端口(6379)。 或者把spring相关配置文件贴出来一下。 127.0.0.1:26379 127.0.0.1:26380 127.0.0.1:26381

redis 集群是哪个版

Redis官方集群(Redis Cluster)推荐4.0以上版本,这个版本对集群做了很多优化和问题修复 其他模式集群 3.2以上即可 redis集群部署过程可参考: Redis集群(Redis Cluster)安装部署

redis 集群是哪个版

Redis官方集群(Redis Cluster)推荐4.0以上版本,这个版本对集群做了很多优化和问题修复 其他模式集群 3.2以上即可 redis集群部署过程可参考: Redis集群(Redis Cluster)安装部署

专题教程

相关文章

更多

最近更新

更多