redis教程

redis 命令,redis入门指南,redis 安装,redis教程,redis视频教程,redis pdf电子书下载,redis免费视频教程,redis视频教程下载

redis删除集群节点-redis集群管理

2016-07-21| 发布: | 浏览: 1922 |保存PDF

先查看一下集群节点信息:
192.168.56.101:6382> cluster nodes
03596d92625f1b778f29eb4a9128d92809dfd79a 192.168.56.101:6381 master - 0 1468857421626 2 connected 5795-10922
e6d316a0dcd7cfcc98de645d86989d5527e86e55 192.168.56.101:6383 master - 0 1468857422639 4 connected 0-332 5461-5794 10923-11255
b1939026deb80fedde7bdb22c1df3ecfaa72f608 192.168.56.101:6380 master - 0 1468857420614 1 connected 333-5460
6aa027917d223b8fedd42893a89fb0e2c07c8b27 192.168.56.101:6382 myself,master - 0 0 3 connected 11256-16383


删除集群中的某一个节点,操作步骤如下:

1、 将这个节点上的所有插槽转移到其他节点上;
a) 假设要删除6383这个节点
b) 执行脚本:[root@master redis-cluster]# /opt/redis/redis-3.2.1/src/redis-trib.rb reshard 192.168.56.101:6383
c) 选择需要转移的插槽的数量,因为6383有1000个,所以转移1000个
d) 输入转移的节点的id,我们转移到6380节点:b1939026deb80fedde7bdb22c1df3ecfaa72f608
e) 输入插槽来源id,也就是6383的id:e6d316a0dcd7cfcc98de645d86989d5527e86e55
f) 输入done,开始转移


查看集群结点信息,可以看到6383节点已经没有插槽了:

192.168.56.101:6382> cluster nodes
03596d92625f1b778f29eb4a9128d92809dfd79a 192.168.56.101:6381 master - 0 1468857808764 2 connected 5795-10922
e6d316a0dcd7cfcc98de645d86989d5527e86e55 192.168.56.101:6383 master - 0 1468857807748 4 connected
b1939026deb80fedde7bdb22c1df3ecfaa72f608 192.168.56.101:6380 master - 0 1468857809781 5 connected 0-5794 10923-11255
6aa027917d223b8fedd42893a89fb0e2c07c8b27 192.168.56.101:6382 myself,master - 0 0 3 connected 11256-16383


2、使用redis-trib.rb del-node删除节点

del-node host:port node_id
[root@master redis-cluster]# /opt/redis/redis-3.2.1/src/redis-trib.rb del-node 192.168.56.101:6383 e6d316a0dcd7cfcc98de645d86989d5527e86e55
>>> Removing node e6d316a0dcd7cfcc98de645d86989d5527e86e55 from cluster 192.168.56.101:6383
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.


查看集群结点信息:

192.168.56.101:6382> cluster nodes
03596d92625f1b778f29eb4a9128d92809dfd79a 192.168.56.101:6381 master - 0 1468858070962 2 connected 5795-10922
b1939026deb80fedde7bdb22c1df3ecfaa72f608 192.168.56.101:6380 master - 0 1468858071980 5 connected 0-5794 10923-11255
6aa027917d223b8fedd42893a89fb0e2c07c8b27 192.168.56.101:6382 myself,master - 0 0 3 connected 11256-16383


书生参考网络整理


宝贝推荐

系列教程

大家都在看

热门访问