redis cluster节点管理测试

###
#redis v3.2.0
###
添加节点:
1.添加master节点
170 ./redis-trib.rb add-node 127.0.0.1:7007 127.0.0.1:7001
171 ./redis01/redis-cli -c -p 7001

2.添加slave节点
172 ./redis-trib.rb add-node --slave --master-id 66e8b4749c12f8656721d233cdff49fb96288cae 127.0.0.1:7008 127.0.0.1:7001

3.重分配slot
173 ./redis-trib.rb reshard 127.0.0.1:7007
175 ./redis01/redis-cli -c -p 7001

4.检查集群状态
./redis-trib.rb check 127.0.0.1:7001

5.7008由7007的从变为7003的从 67b8e958d1f2021b20aaf3e46a0d849155d68bb6为7003的id
[root@vhost02 redis-cluster]# ./redis01/redis-cli -p 7008
127.0.0.1:7008> cluster replicate 67b8e958d1f2021b20aaf3e46a0d849155d68bb6
OK

6.删除从节点7008
[root@vhost02 redis-cluster]# ./redis-trib.rb del-node 127.0.0.1:7001 'ac00db3e8b1fea38fd819b06aecd29ac5aeebdc5'
>>> Removing node ac00db3e8b1fea38fd819b06aecd29ac5aeebdc5 from cluster 127.0.0.1:7001
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.
[root@vhost02 redis-cluster]# ./redis01/redis-cli -p 7001
127.0.0.1:7001> cluster nodes
61c9ff160da328b839e29b74c78756183b4053f2 127.0.0.1:7001 myself,master - 0 0 1 connected 333-5460
72b40e0c38bc0f937868aaf22fd729b33c90c3e8 127.0.0.1:7005 slave 0ad1c1a92a62194862ab4782a74e87c31071ee1b 0 1463390179835 5 connected
67b8e958d1f2021b20aaf3e46a0d849155d68bb6 127.0.0.1:7003 master - 0 1463390181855 3 connected 11256-16383
0e96b53f8b875d5c9483538c60a0ebe5992d9b11 127.0.0.1:7004 slave 61c9ff160da328b839e29b74c78756183b4053f2 0 1463390178827 4 connected
0ad1c1a92a62194862ab4782a74e87c31071ee1b 127.0.0.1:7002 master - 0 1463390182863 2 connected 5795-10922
66e8b4749c12f8656721d233cdff49fb96288cae 127.0.0.1:7007 master - 0 1463390180845 7 connected 0-332 5461-5794 10923-11255
5a9c5adb1d9b20b29e877569587b0fd57a265866 127.0.0.1:7006 slave 67b8e958d1f2021b20aaf3e46a0d849155d68bb6 0 1463390177813 6 connected
127.0.0.1:7001>
7.删除主节点
166 ./redis-trib.rb reshard 127.0.0.1:7007
[root@vhost02 redis-cluster]# ./redis01/redis-cli -p 7001
127.0.0.1:7001> cluster nodes
61c9ff160da328b839e29b74c78756183b4053f2 127.0.0.1:7001 myself,master - 0 0 8 connected 0-5794 10923-11255
72b40e0c38bc0f937868aaf22fd729b33c90c3e8 127.0.0.1:7005 slave 0ad1c1a92a62194862ab4782a74e87c31071ee1b 0 1463391006710 5 connected
67b8e958d1f2021b20aaf3e46a0d849155d68bb6 127.0.0.1:7003 master - 0 1463391004680 3 connected 11256-16383
0e96b53f8b875d5c9483538c60a0ebe5992d9b11 127.0.0.1:7004 slave 61c9ff160da328b839e29b74c78756183b4053f2 0 1463391005190 8 connected
0ad1c1a92a62194862ab4782a74e87c31071ee1b 127.0.0.1:7002 master - 0 1463391005700 2 connected 5795-10922
66e8b4749c12f8656721d233cdff49fb96288cae 127.0.0.1:7007 master - 0 1463391003663 7 connected
5a9c5adb1d9b20b29e877569587b0fd57a265866 127.0.0.1:7006 slave 67b8e958d1f2021b20aaf3e46a0d849155d68bb6 0 1463391007719 6 connected
127.0.0.1:7001>

[root@vhost02 redis-cluster]# ./redis-trib.rb del-node 127.0.0.1:7001 '66e8b4749c12f8656721d233cdff49fb96288cae'
>>> Removing node 66e8b4749c12f8656721d233cdff49fb96288cae from cluster 127.0.0.1:7001
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.
[root@vhost02 redis-cluster]# ./redis01/redis-cli -p 7001
127.0.0.1:7001> cluster nodes
61c9ff160da328b839e29b74c78756183b4053f2 127.0.0.1:7001 myself,master - 0 0 8 connected 0-5794 10923-11255
72b40e0c38bc0f937868aaf22fd729b33c90c3e8 127.0.0.1:7005 slave 0ad1c1a92a62194862ab4782a74e87c31071ee1b 0 1463392081016 5 connected
67b8e958d1f2021b20aaf3e46a0d849155d68bb6 127.0.0.1:7003 master - 0 1463392083543 3 connected 11256-16383
0e96b53f8b875d5c9483538c60a0ebe5992d9b11 127.0.0.1:7004 slave 61c9ff160da328b839e29b74c78756183b4053f2 0 1463392081521 8 connected
0ad1c1a92a62194862ab4782a74e87c31071ee1b 127.0.0.1:7002 master - 0 1463392082532 2 connected 5795-10922
5a9c5adb1d9b20b29e877569587b0fd57a265866 127.0.0.1:7006 slave 67b8e958d1f2021b20aaf3e46a0d849155d68bb6 0 1463392084549 6 connected

上一篇:Maven仓库—Nexus环境搭建及使用


下一篇:Python-模块,以及使用文本中的数据