[root@master1 ~]# cd /var/lib/redis/6379/
[root@master1 6379]# ls
appendonly.aof dump.rdb nodes-6379.conf
[root@master1 6379]# rm -rf *
redis迁移槽位
[root@master1 ~]# redis-cli --cluster reshard 192.168.73.200:6379
How many slots do you want to move (from 1 to 16384)? 4096 '//要迁移多少个槽'
What is the receiving node ID? 99521b7fd126b694bcb9a22ffa5a490f31f66543 '//迁移到哪个节点,数据节点id'
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.
'//要求输入源节点的id,这里因为原本有三个节点,输入done表示结束'
Source node #1: 7f112f82bcf28a5d0627ea81b48cb76f4ea8605d
Source node #2: df195a34a91d756157a0fda7c71e99d5bd8fad09
Source node #3: a233a23541f431107fed79908318394d8bb30b51
Source node #4: done
'//最后会有一个迁移方案,输入yes表示同意,迁移开始。输入no表示不同意,重新设置迁移方案。''//确认是否迁移成功'
[root@master1 ~]# redis-cli -h 192.168.73.200 -p 6379
192.168.100.41:6379> cluster nodes
...省略内容
迁移后检测各个节点槽的均衡性
[root@master1 ~]# redis-cli --cluster rebalance 192.168.73.200:6379
>>> Performing Cluster Check (using node 192.168.100.41:6379)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
*** No rebalancing needed! All nodes are within the 2.00% threshold.
可以看出,节点负责的槽数据差异在2%以内,因此槽分配均衡
[root@master1 ~]# redis-cli --cluster rebalance --cluster-threshold 1 192.168.73.200:6379
>>> Performing Cluster Check (using node 192.168.73.200:6379)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
*** No rebalancing needed! All nodes are within the 1.00% threshold.