redis搭建集群 - 删除节点

集群删除节点

删除redis服务:
    192.168.2.111:6381主节点
    192.168.2.111:6382从节点


一: 删除主节点
1:先清除主节点所有的哈希槽 -- 分片
[root@192 ~]# redis-cli --cluster reshard 192.168.2.111:6381
    结果:
    >>> Performing Cluster Check (using node 192.168.2.111:6381)
    M: 4ca16d842ea07379be11371aa2381529a9b5d7bc 192.168.2.111:6381
       slots:[0-165],[5461-5627],[10923-11088] (499 slots) master
    S: f3dbdddc6c2dc23e1dde2e6e6662c6c5ebf167e9 192.168.2.111:6380
       slots: (0 slots) slave
       replicates 75b477ef4967c1bf50502cb834df3fd5660cfa22
    M: ebc80d8dcabe30645b96fdfe08de84f52a42cbff 192.168.2.113:6379
       slots:[11089-16383] (5295 slots) master
       1 additional replica(s)
    M: 75b477ef4967c1bf50502cb834df3fd5660cfa22 192.168.2.112:6379
       slots:[5628-10922] (5295 slots) master
       1 additional replica(s)
    M: 63cfbaf1e7d7d9fce095d0f485776ba15404bf8a 192.168.2.111:6379
       slots:[166-5460] (5295 slots) master
       1 additional replica(s)
    S: e6d09dcaa252336190e4e8747a60d067572d5156 192.168.2.112:6380
       slots: (0 slots) slave
       replicates ebc80d8dcabe30645b96fdfe08de84f52a42cbff
    S: 5da5d0d7f7036c971926a821b33764fb2c78ea50 192.168.2.113:6380
       slots: (0 slots) slave
       replicates 63cfbaf1e7d7d9fce095d0f485776ba15404bf8a
    [OK] All nodes agree about slots configuration.
    >>> Check for open slots...
    >>> Check slots coverage...
    [OK] All 16384 slots covered.
    How many slots do you want to move (from 1 to 16384)? 500
    解释:您想移动多少个槽
    What is the receiving node ID? 63cfbaf1e7d7d9fce095d0f485776ba15404bf8a
    解释:接收节点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: 4ca16d842ea07379be11371aa2381529a9b5d7bc 这里添加要删除槽的节点id
    Source node #2: done
    
    
2: 查看节点信息
[root@192 ~]# redis-cli --cluster check 192.168.2.111:6381
结果:
    >>> Performing Cluster Check (using node 192.168.2.111:6381)
    M: 4ca16d842ea07379be11371aa2381529a9b5d7bc 192.168.2.111:6381
    slots: (0 slots) master
    节点的哈希槽已经清空了
    
3:删除节点    
[root@192 ~]# redis-cli --cluster del-node 192.168.2.111:6381 4ca16d842ea07379be11371aa2381529a9b5d7bc
结果:
>>> Removing node 4ca16d842ea07379be11371aa2381529a9b5d7bc from cluster 192.168.2.111:6381
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.





二:删除从节点
redis-cli --cluster  del-node host:port node_id

[root@192 ~]# redis-cli --cluster  del-node 192.168.2.111:6382 cc3cfe29129ff7a5bcb2c5f803e8f4614b291373
    结果:
    >>> Removing node cc3cfe29129ff7a5bcb2c5f803e8f4614b291373 from cluster 192.168.2.111:6382
    >>> Sending CLUSTER FORGET messages to the cluster...
    >>> SHUTDOWN the node.
发布了20 篇原创文章 · 获赞 8 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/web_snail/article/details/89384471