删除一个slave节点:
# redis-trib.rb del-node 192.168.2.202:6380 e4dc23dc67418bf66c6c63655110612cb9516aff
// del-node host:port node-id
>>> Removing node e4dc23dc67418bf66c6c63655110612cb9516aff from cluster 192.168.2.202:6380
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.
查看集群节点信息:
# redis-trib.rb check 192.168.2.100:6379 (确认slave节点已经删除)
>>> Performing Cluster Check (using node 192.168.2.100:6379)
M: 098e7eb756b6047fde988ab3c0b7189e1724ecf5 192.168.2.100:6379
slots:333-5460 (5128 slots) master
1 additional replica(s)
S: 7119dec91b086ca8fe69f7878fa42b1accd75f0f 192.168.2.100:6380
slots: (0 slots) slave
replicates 5844b4272c39456b0fdf73e384ff8c479547de47
删除一个master节点:
先移除master身上的hash slot,再删除master。
目前不能直接删除slot,要把删除的master的slot迁移到其他master节点上。
# redis-trib.rb reshard 192.168.2.100:6379 //slot迁移到2.100上
How many slots do you want to move (from 1 to 16384)? 1000
//迁移多少个slot?(要删除的master节点上有多少个slot)
What is the receiving node ID? 098e7eb756b6047fde988ab3c0b7189e1724ecf5
//迁移到那个节点上,ID是多少?(slot迁移给谁,写谁的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:8326ff0be199fa0d4db74f0ebcc58f27e65991b4
//被删除的master的ID
Source node #2:done //表示结束
... ...
Do you want to proceed with the proposed reshard plan (yes/no)? yes
//是否满意hash slot移动计划?
把要删除的master移除集群:
# redis-trib.rb del-node 192.168.2.100:6379 8326ff0be199fa0d4db74f0ebcc58f27e65991b4
//集群中任意节点的IP:端口、要删除的master的ID
更改slave节点隶属的master:
当前配置中,192.168.2.100:6380隶属于192.168.2.200:6379
将192.168.2.100:6380的隶属更改为192.168.2.100:6379
1、登录方式指定要更改隶属关系的IP、端口
2、更改隶属关系时,直接指定新的master节点的ID
# redis-cli -c -h 192.168.2.100 -p 6380
> cluster nodes
5844b4272c39456b0fdf73e384ff8c479547de47 192.168.2.200:6379 master - 0 1527165062499 3 connected 5795-10922
2faf68564a70372cfc06c1afff197019cc6a39f3 192.168.2.201:6380 slave 3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69 0 1527165063511 6 connected
098e7eb756b6047fde988ab3c0b7189e1724ecf5 192.168.2.100:6379 master - 0 1527165060482 10 connected 0-5794 10923-11255
227f51028bbe827f27b4e40ed7a08fcc7d8df969 192.168.2.200:6380 slave 098e7eb756b6047fde988ab3c0b7189e1724ecf5 0 1527165059474 10 connected
7119dec91b086ca8fe69f7878fa42b1accd75f0f 192.168.2.100:6380 myself,slave 5844b4272c39456b0fdf73e384ff8c479547de47 0 0 2 connected
3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69 192.168.2.201:6379 master - 0 1527165058465 5 connected 11256-16383
192.168.2.100:6380>
192.168.2.100:6380> cluster replicate 098e7eb756b6047fde988ab3c0b7189e1724ecf5
OK
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。