redis集群的删除节点(缩减),以Redis6.0.6集群的增加节点文章的redis集群搭建基础上删除2个节点
删除后来新增的节点7007和7008
由于7007主节点的从节点是7008,删除7008从节点
# 查看节点信息,确认要删除的节点id
[root@localhost ~]# redis-cli -c -p 7001 cluster nodes
4cc528ff35eadeb795af874fefc0009e555774d6 192.168.10.3:7006@17006 slave db2ae554b712331f12e728fc7d246c89fa79a78d 0 1618559931861 3 connected
f202aff7ae33e68a6d331b34b5c32ca71d91e8f3 192.168.10.1:7001@17001 myself,master - 0 1618559930000 1 connected 1365-5460
c528e42056573406479b0af5f5b089ec990836a5 192.168.10.1:7002@17002 slave 2e3f01f01627f0249c9bc5a5e6808c8805ffd40b 0 1618559930858 5 connected
17c719e9919823b4e2da15d1a64412de63a4eb0c 192.168.10.4:7008@17008 slave 3da86e6d25d38d8fb9af80e87bfd5aeff867e309 0 1618559931000 8 connected
2e3f01f01627f0249c9bc5a5e6808c8805ffd40b 192.168.10.3:7005@17005 master - 0 1618559932062 5 connected 12288-16383
dbecff7305a5ad51f42052548253f73419b714dc 192.168.10.2:7004@17004 slave f202aff7ae33e68a6d331b34b5c32ca71d91e8f3 0 1618559931561 1 connected
3da86e6d25d38d8fb9af80e87bfd5aeff867e309 192.168.10.4:7007@17007 master - 0 1618559931000 8 connected 0-1364 5461-6826 10923-12287
db2ae554b712331f12e728fc7d246c89fa79a78d 192.168.10.2:7003@17003 master - 0 1618559931561 3 connected 6827-10922
# 删除从7008 salve从节点
[root@localhost ~]# redis-cli --cluster del-node 192.168.10.4:7008 17c719e9919823b4e2da15d1a64412de63a4eb0c
>>> Removing node 17c719e9919823b4e2da15d1a64412de63a4eb0c from cluster 192.168.10.4:7008
>>> Sending CLUSTER FORGET messages to the cluster...
>>> Sending CLUSTER RESET SOFT to the deleted node.
# 再次查看集群节点信息,看到已经删除成功
[root@localhost ~]# redis-cli -c -p 7001 cluster nodes
4cc528ff35eadeb795af874fefc0009e555774d6 192.168.10.3:7006@17006 slave db2ae554b712331f12e728fc7d246c89fa79a78d 0 1618559959547 3 connected
f202aff7ae33e68a6d331b34b5c32ca71d91e8f3 192.168.10.1:7001@17001 myself,master - 0 1618559959000 1 connected 1365-5460
c528e42056573406479b0af5f5b089ec990836a5 192.168.10.1:7002@17002 slave 2e3f01f01627f0249c9bc5a5e6808c8805ffd40b 0 1618559958544 5 connected
2e3f01f01627f0249c9bc5a5e6808c8805ffd40b 192.168.10.3:7005@17005 master - 0 1618559957941 5 connected 12288-16383
dbecff7305a5ad51f42052548253f73419b714dc 192.168.10.2:7004@17004 slave f202aff7ae33e68a6d331b34b5c32ca71d91e8f3 0 1618559958042 1 connected
3da86e6d25d38d8fb9af80e87bfd5aeff867e309 192.168.10.4:7007@17007 master - 0 1618559958000 8 connected 0-1364 5461-6826 10923-12287
db2ae554b712331f12e728fc7d246c89fa79a78d 192.168.10.1:7003@17003 master - 0 1618559958946 3 connected 6827-10922
[root@localhost ~]#
移动7007主节点的槽位到其他节点中(不移动删除不了,把7007主节点的槽位移动到7003主节点中)
# 对7007主节点进行操作
[root@localhost ~]# redis-cli --cluster reshard 192.168.10.4:7007
>>> Performing Cluster Check (using node 192.168.10.4:7007)
M: 3da86e6d25d38d8fb9af80e87bfd5aeff867e309 192.168.10.4:7007
slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master
M: 2e3f01f01627f0249c9bc5a5e6808c8805ffd40b 192.168.10.3:7005
slots:[12288-16383] (4096 slots) master
1 additional replica(s)
M: db2ae554b712331f12e728fc7d246c89fa79a78d 192.168.10.2:7003
slots:[6827-10922] (4096 slots) master
1 additional replica(s)
M: f202aff7ae33e68a6d331b34b5c32ca71d91e8f3 192.168.10.1:7001
slots:[1365-5460] (4096 slots) master
1 additional replica(s)
S: c528e42056573406479b0af5f5b089ec990836a5 192.168.10.1:7002
slots: (0 slots) slave
replicates 2e3f01f01627f0249c9bc5a5e6808c8805ffd40b
S: 4cc528ff35eadeb795af874fefc0009e555774d6 192.168.10.3:7006
slots: (0 slots) slave
replicates db2ae554b712331f12e728fc7d246c89fa79a78d
S: dbecff7305a5ad51f42052548253f73419b714dc 192.168.10.2:7004
slots: (0 slots) slave
replicates f202aff7ae33e68a6d331b34b5c32ca71d91e8f3
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
# 7007节点有多少槽位就写多少
How many slots do you want to move (from 1 to 16384)? 4096
# 要移动到哪个节点,写7003主节点id
What is the receiving node ID? db2ae554b712331f12e728fc7d246c89fa79a78d
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.
# 从哪个节点移动,写7007主节点id
Source node #1: 3da86e6d25d38d8fb9af80e87bfd5aeff867e309
Source node #2: done
······
忽略输出内容
······
Moving slot 12280 from 3da86e6d25d38d8fb9af80e87bfd5aeff867e309
Moving slot 12281 from 3da86e6d25d38d8fb9af80e87bfd5aeff867e309
Moving slot 12282 from 3da86e6d25d38d8fb9af80e87bfd5aeff867e309
Moving slot 12283 from 3da86e6d25d38d8fb9af80e87bfd5aeff867e309
Moving slot 12284 from 3da86e6d25d38d8fb9af80e87bfd5aeff867e309
Moving slot 12285 from 3da86e6d25d38d8fb9af80e87bfd5aeff867e309
Moving slot 12286 from 3da86e6d25d38d8fb9af80e87bfd5aeff867e309
Moving slot 12287 from 3da86e6d25d38d8fb9af80e87bfd5aeff867e309
# 是否执行以上操作,输入yes确认执行
Do you want to proceed with the proposed reshard plan (yes/no)? yes
······
忽略输出内容
······
Moving slot 12281 from 192.168.10.4:7007 to 192.168.10.2:7003:
Moving slot 12282 from 192.168.10.4:7007 to 192.168.10.2:7003:
Moving slot 12283 from 192.168.10.4:7007 to 192.168.10.2:7003:
Moving slot 12284 from 192.168.10.4:7007 to 192.168.10.2:7003:
Moving slot 12285 from 192.168.10.4:7007 to 192.168.10.2:7003:
Moving slot 12286 from 192.168.10.4:7007 to 192.168.10.2:7003:
Moving slot 12287 from 192.168.10.4:7007 to 192.168.10.2:7003:
[root@localhost ~]#
删除7007主节点
# 查看集群节点信息,确认7007主节点没有槽位
[root@localhost ~]# redis-cli -c -p 7001 cluster nodes
4cc528ff35eadeb795af874fefc0009e555774d6 192.168.10.3:7006@17006 slave db2ae554b712331f12e728fc7d246c89fa79a78d 0 1618561826003 9 connected
f202aff7ae33e68a6d331b34b5c32ca71d91e8f3 192.168.10.1:7001@17001 myself,master - 0 1618561824000 1 connected 1365-5460
c528e42056573406479b0af5f5b089ec990836a5 192.168.10.1:7002@17002 slave 2e3f01f01627f0249c9bc5a5e6808c8805ffd40b 0 1618561826000 5 connected
2e3f01f01627f0249c9bc5a5e6808c8805ffd40b 192.168.10.3:7005@17005 master - 0 1618561825000 5 connected 12288-16383
dbecff7305a5ad51f42052548253f73419b714dc 192.168.10.2:7004@17004 slave f202aff7ae33e68a6d331b34b5c32ca71d91e8f3 0 1618561825501 1 connected
3da86e6d25d38d8fb9af80e87bfd5aeff867e309 192.168.10.4:7007@17007 master - 0 1618561825000 8 connected
db2ae554b712331f12e728fc7d246c89fa79a78d 192.168.10.2:7003@17003 master - 0 1618561826505 9 connected 0-1364 5461-12287
# 删除7007主节点
[root@localhost ~]# redis-cli --cluster del-node 192.168.10.4:7007 3da86e6d25d38d8fb9af80e87bfd5aeff867e309
>>> Removing node 3da86e6d25d38d8fb9af80e87bfd5aeff867e309 from cluster 192.168.10.4:7007
>>> Sending CLUSTER FORGET messages to the cluster...
>>> Sending CLUSTER RESET SOFT to the deleted node.
# 确认集群节点信息,7007 和 7008 两个节点已经删除
[root@localhost ~]# redis-cli -c -p 7001 cluster nodes
4cc528ff35eadeb795af874fefc0009e555774d6 192.168.10.3:7006@17006 slave db2ae554b712331f12e728fc7d246c89fa79a78d 0 1618561873543 9 connected
f202aff7ae33e68a6d331b34b5c32ca71d91e8f3 192.168.10.1:7001@17001 myself,master - 0 1618561873000 1 connected 1365-5460
c528e42056573406479b0af5f5b089ec990836a5 192.168.10.1:7002@17002 slave 2e3f01f01627f0249c9bc5a5e6808c8805ffd40b 0 1618561874000 5 connected
2e3f01f01627f0249c9bc5a5e6808c8805ffd40b 192.168.10.3:7005@17005 master - 0 1618561874544 5 connected 12288-16383
dbecff7305a5ad51f42052548253f73419b714dc 192.168.10.2:7004@17004 slave f202aff7ae33e68a6d331b34b5c32ca71d91e8f3 0 1618561874645 1 connected
db2ae554b712331f12e728fc7d246c89fa79a78d 192.168.10.2:7003@17003 master - 0 1618561873000 9 connected 0-1364 5461-12287
[root@localhost ~]#
取key测试
本文最后记录时间 2024-03-30
文章链接地址:https://wojc.cn/archives/1111.html
本站文章除注明[转载|引用|来源],均为本站原创内容,转载前请注明出处
文章链接地址:https://wojc.cn/archives/1111.html
本站文章除注明[转载|引用|来源],均为本站原创内容,转载前请注明出处