redis集群给新添加的节点分配槽道的操作

一、准备好redis集群如下:

10.211.55.5:8001> cluster nodes da23623c6e915de5256bb2252cd1057d4f29e558 10.211.55.5:8003 master - 0 1538583619331 0 connected
3f3049540ba60e30080847e78ccf832f94961da2 10.211.55.5:8004 slave 6f4a31fc322725fc4ed453a588f344fed4f261bf 0 1538583620339 2 connected
6f4a31fc322725fc4ed453a588f344fed4f261bf 10.211.55.5:8001 myself,master - 0 0 2 connected 5461-10922
8ce851252f32fcab268e77d3b3ed976d57d2f498 10.211.55.5:8000 master - 0 1538583622352 1 connected 0-5460
da7d09090520a0e6287ea12fe7f48225d6665f68 10.211.55.5:8002 master - 0 1538583621346 3 connected 10923-16383
10.211.55.5:8001>

二、给8003节点分配50个槽道

执行命令如下,8004是集群中的任意一个节点
[root@cenos01 src]# ./redis-trib.rb reshard 10.211.55.5:8004

Performing Cluster Check (using node 10.211.55.5:8004)
S: 3f3049540ba60e30080847e78ccf832f94961da2 10.211.55.5:8004
slots: (0 slots) slave
replicates 6f4a31fc322725fc4ed453a588f344fed4f261bf
M: da7d09090520a0e6287ea12fe7f48225d6665f68 10.211.55.5:8002
slots:10923-16383 (5461 slots) master
0 additional replica(s)
M: da23623c6e915de5256bb2252cd1057d4f29e558 10.211.55.5:8003
slots: (0 slots) master
0 additional replica(s)
M: 6f4a31fc322725fc4ed453a588f344fed4f261bf 10.211.55.5:8001
slots:5461-10922 (5462 slots) master
1 additional replica(s)
M: 8ce851252f32fcab268e77d3b3ed976d57d2f498 10.211.55.5:8000
slots:0-5460 (5461 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)? 50

What is the receiving node ID? da23623c6e915de5256bb2252cd1057d4f29e558
*** The specified node is not known or not a master, please retry.
What is the receiving node ID? da23623c6e915de5256bb2252cd1057d4f29e558
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.
Source node #1:all
这里使用all将会自动计算从所有主节点平均获取槽道移动
使用done,注意输入master节点的id,从cluster nodes中粘贴

回车后,以下输入yes,就分配完成后

Do you want to proceed with the proposed reshard plan (yes/no)? yes

查看分配后的结果:

10.211.55.5:8001> cluster nodes
da23623c6e915de5256bb2252cd1057d4f29e558 10.211.55.5:8003 master - 0 1538584291512 5 connected 0-15 5461-5477 10923-10938
3f3049540ba60e30080847e78ccf832f94961da2 10.211.55.5:8004 slave 6f4a31fc322725fc4ed453a588f344fed4f261bf 0 1538584288492 2 connected
6f4a31fc322725fc4ed453a588f344fed4f261bf 10.211.55.5:8001 myself,master - 0 0 2 connected 5478-10922
8ce851252f32fcab268e77d3b3ed976d57d2f498 10.211.55.5:8000 master - 0 1538584293523 1 connected 16-5460
da7d09090520a0e6287ea12fe7f48225d6665f68 10.211.55.5:8002 master - 0 1538584292518 3 connected 10939-16383

重新分配槽道,不能重新操作有数据的槽道,空槽道可以reshard,有数 据的需要手动迁移数据后在迁移槽道

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值