【缓存-Redis】Redis5.0.5三主三从升级四主四从的槽迁移方案

1.添加集群节点

原三主三从redis集群:

(master-node-1)  ip1:port1  
(master-node-2)  ip2:port2 
(master-node-3)  ip3:port3  
(slave-node-1)  ip4:port4  
(slave-node-2)  ip5:port5
(slave-node-3)  ip6:port6

添加俩个新节点(master-node-4) ip7:port7   (slave-node-4)ip8:port8

添加主节点(master-node-4)  redis-cli -a pwd --cluster add-node IP7:PORT7 cluster-ip:cluster-port(集群中的任意ip和port)
为主节点添加从节点  redis-cli -a pwd --cluster add-node IP8:PORT8 cluster-ip:cluster-port --cluster-slave --cluster-master-id master-node-4 (集群中的任意ip和port)

2.计算槽迁移数量

cluster nodes查询集群主节点的槽数量:
  master-node-1槽数量5461
  master-node-2槽数量5462
  master-node-3槽数量5461

槽总量16384,4各节点平均分配,每个节点4096个槽,所以需要迁移:
  master-node-1 -> master-node-4需要迁移1365
  master-node-2 -> master-node-4需要迁移1366
  master-node-3 -> master-node-4需要迁移1365

3.执行以下命令进行迁移

redis-cli -a pwd --cluster reshard cluster-ip:cluster-port --cluster-from master-node-1 --cluster-to master-node-4 --cluster-slots 1365 --cluster-yes --cluster-timeout 15000 --cluster-pipeline 100 --cluster-replace
redis-cli -a pwd --cluster reshard cluster-ip:cluster-port --cluster-from master-node-2 --cluster-to master-node-4 --cluster-slots 1366 --cluster-yes --cluster-timeout 15000 --cluster-pipeline 100 --cluster-replace 
redis-cli -a pwd --cluster reshard cluster-ip:cluster-port --cluster-from master-node-3 --cluster-to master-node-4 --cluster-slots 1365 --cluster-yes --cluster-timeout 15000 --cluster-pipeline 100 --cluster-replace

4.迁移完成查看槽数量(各个槽数量应为4096)及集群状态

redis-cli -a 【pwd】 -h 【IP1 】-p 【PORT1 】-c cluster info
redis-cli -a 【pwd 】-h 【IP1 】-p 【PORT1 】-c cluster nodes

你可能感兴趣的:(【缓存-Redis】Redis5.0.5三主三从升级四主四从的槽迁移方案)