redis集群迁移过程中意外中断如何恢复

一扩容并手动发现节点:

redis-server /opt/redis_6390/conf/redis_6390.conf
 redis-server /opt/redis_6391/conf/redis_6391.conf
 ps -ef|grep redis

 

 #手动发现节点

redis-cli -c -h 10.0.0.101 -p 6380 cluster meet 10.0.0.101 6390
redis-cli -c -h 10.0.0.101 -p 6380 cluster meet 10.0.0.101 6391
redis-cli -c -h 10.0.0.101 -p 6380 cluster nodes

 

 

#重新分配槽位
redis-cli --cluster reshard 10.0.0.101:6380

#第一次交互:每个节点最终分配多少个槽
How many slots do you want to move (from 1 to 16384)? 4096

#第二次交互:接受节点的ID
What is the receiving node ID? 6390的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.
Source node #1:all

#第四次交互:确认信息
Do you want to proceed with the proposed reshard plan (yes/no)? yes
在迁移的过程中,同时干掉6390节点(kill掉6390的id)

 

 

二:查看

[root@oldboyedu conf]# redis-server /opt/redis_6390/conf/redis_6390.conf

[root@oldboyedu conf]# redis-cli -h 10.0.0.101 -p 6390
10.0.0.101:6390> CLUSTER nodes

 

 

9a2b56caa91a3084ce4f17acc7c1d90912d6dd97 10.0.0.101:6390@16390 myself,master - 0 1626149087172 19 connected 0-227 2958-3051 [3052-<-c186a784c585abf99866ea26c76dcd13dce2d8e0]

 #此处代表此槽位在接受数据

三:修复

方法1:手动修复

redis-cli -c -h 10.0.0.101 -p 6380  CLUSTER SETSLOT 3052 STABLE 

方法2:自动修复

redis-cli --cluster fix 10.0.0.101:6380

 

posted on 2021-07-13 11:28  弓长三寿  阅读(263)  评论(0编辑  收藏  举报