靳闯博客 记录是一种习惯 、分享是一种态度
  • 波浪
  • 波浪
  • 波浪
  • 波浪
Redis6.0.6集群 删除节点
发表于: | 分类: 技术积累 | 标签: Linux Centos7 Redis

redis集群的删除节点(缩减),以Redis6.0.6集群的增加节点文章的redis集群搭建基础上删除2个节点

删除后来新增的节点7007和7008


由于7007主节点的从节点是7008,删除7008从节点

redel.png

# 查看节点信息,确认要删除的节点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主节点中)

redel1.png

# 对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主节点

redel2.png

# 查看集群节点信息,确认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测试

redel3.png


商业转载请联系作者获得授权,非商业转载请注明出处 本文地址:https://me.jinchuang.org/archives/1111.html

如果这篇文章帮助到了你,我感到十分荣幸!


📬 评论留言 ↴

icon_mrgreen.pngicon_neutral.pngicon_twisted.pngicon_arrow.pngicon_eek.pngicon_smile.pngicon_confused.pngicon_cool.pngicon_evil.pngicon_biggrin.pngicon_idea.pngicon_redface.pngicon_razz.pngicon_rolleyes.pngicon_wink.pngicon_cry.pngicon_surprised.pngicon_lol.pngicon_mad.pngicon_sad.pngicon_exclaim.pngicon_question.png2018new_aini_org.png2018new_baobao_thumb.png2018new_erha_org.png2018new_kuxiao_thumb.png2018new_yun_thumb.png2018new_hufen_thumb.png2018new_gui_org.png2018new_xiaoerbuyu_org.png2018new_heixian_thumb.png2018new_wabi_thumb.png2018new_tianping_thumb.png

TOP