|
./bin/redis-trib.rb reshard 10.0.18.147:7006 (这个是搞砸的,不要按照这个操作!)
>>> Performing Cluster Check (using node 10.0.18.147:7006)
M: 5cbec92f52fbe9da7cd643cd34e87055c5358018 10.0.18.147:7006
slots:0-499 (500 slots) master #10.0.18.147:7006节点的slot数量是500
0 additional replica(s)
S: b3798ae7f13e4fca57e7a505eca0dae1f19ce4c3 10.0.18.145:7001
slots: (0 slots) slave
replicates 2e2f563a1467c2515857d70d762c26b06faabbd4
M: c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b 10.0.18.147:7004
slots:500-5460 (4961 slots) master
1 additional replica(s)
S: 4eeee08df0ee4ee0db34b39bf6922a24edb356d8 10.0.18.146:7003
slots: (0 slots) slave
replicates c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b
M: 2e2f563a1467c2515857d70d762c26b06faabbd4 10.0.18.145:7000
slots:10923-16383 (5461 slots) master
1 additional replica(s)
S: 37ea68d5cfd3953bde636656dd2250d5f6a7029d 10.0.18.147:7005
slots: (0 slots) slave
replicates faee6763e5f591d9d63df8d841041255ae7992f3
M: faee6763e5f591d9d63df8d841041255ae7992f3 10.0.18.146:7002
slots:5461-10922 (5462 slots) master
1 additional replica(s)
[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 #输入500
What is the receiving node ID? 5cbec92f52fbe9da7cd643cd34e87055c5358018 #输入10.0.18.147:7006节点的node 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:c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b #接收这500个slot的主节点是10.0.18.147:7004
Source node #2:done #输入done
………………
Moving slot 993 from c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b
Moving slot 994 from c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b
Moving slot 995 from c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b
Moving slot 996 from c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b
Moving slot 997 from c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b
Moving slot 998 from c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b
Moving slot 999 from c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b
Do you want to proceed with the proposed reshard plan (yes/no)? yes
………………
Moving slot 996 from 10.0.18.147:7004 to 10.0.18.147:7006:
Moving slot 997 from 10.0.18.147:7004 to 10.0.18.147:7006:
Moving slot 998 from 10.0.18.147:7004 to 10.0.18.147:7006:
Moving slot 999 from 10.0.18.147:7004 to 10.0.18.147:7006:
搞砸了,本来是想将10.0.18.147:7006的500个slot转移到10.0.18.147:7004的,结果搞反掉了,入下:
#./bin/redis-cli -h 10.0.18.146 -p 7002 cluster nodes
5cbec92f52fbe9da7cd643cd34e87055c5358018 10.0.18.147:7006 master - 0 1476956724238 7 connected 0-999
37ea68d5cfd3953bde636656dd2250d5f6a7029d 10.0.18.147:7005 slave faee6763e5f591d9d63df8d841041255ae7992f3 0 1476956726241 6 connected
faee6763e5f591d9d63df8d841041255ae7992f3 10.0.18.146:7002 myself,master - 0 0 3 connected 5461-10922
c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b 10.0.18.147:7004 master - 0 1476956724237 5 connected 1000-5460
4eeee08df0ee4ee0db34b39bf6922a24edb356d8 10.0.18.146:7003 slave c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b 0 1476956727243 5 connected
b3798ae7f13e4fca57e7a505eca0dae1f19ce4c3 10.0.18.145:7001 slave 2e2f563a1467c2515857d70d762c26b06faabbd4 0 1476956725239 2 connected
2e2f563a1467c2515857d70d762c26b06faabbd4 10.0.18.145:7000 master - 0 1476956726241 1 connected 10923-16383
请原谅我的失误!再来一次:
#./bin/redis-trib.rb reshard 10.0.18.147:7006
>>> Performing Cluster Check (using node 10.0.18.147:7006)
M: 5cbec92f52fbe9da7cd643cd34e87055c5358018 10.0.18.147:7006
slots:0-999 (1000 slots) master #现在18.147:7006节点有1000个slot了
0 additional replica(s)
S: b3798ae7f13e4fca57e7a505eca0dae1f19ce4c3 10.0.18.145:7001
slots: (0 slots) slave
replicates 2e2f563a1467c2515857d70d762c26b06faabbd4
M: c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b 10.0.18.147:7004
slots:1000-5460 (4461 slots) master
1 additional replica(s)
S: 4eeee08df0ee4ee0db34b39bf6922a24edb356d8 10.0.18.146:7003
slots: (0 slots) slave
replicates c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b
M: 2e2f563a1467c2515857d70d762c26b06faabbd4 10.0.18.145:7000
slots:10923-16383 (5461 slots) master
1 additional replica(s)
S: 37ea68d5cfd3953bde636656dd2250d5f6a7029d 10.0.18.147:7005
slots: (0 slots) slave
replicates faee6763e5f591d9d63df8d841041255ae7992f3
M: faee6763e5f591d9d63df8d841041255ae7992f3 10.0.18.146:7002
slots:5461-10922 (5462 slots) master
1 additional replica(s)
[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)? 1000 #输入1000
What is the receiving node ID? c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b #输入10.0.18.147:7004节点的node id,因为接收这1000个slot的节点是10.0.18.147:7004
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:5cbec92f52fbe9da7cd643cd34e87055c5358018 #输入10.0.18.147:7006节点的node id,因为是要从此节点转移slot。
Source node #2:done #输入done
…………
Moving slot 996 from 5cbec92f52fbe9da7cd643cd34e87055c5358018
Moving slot 997 from 5cbec92f52fbe9da7cd643cd34e87055c5358018
Moving slot 998 from 5cbec92f52fbe9da7cd643cd34e87055c5358018
Moving slot 999 from 5cbec92f52fbe9da7cd643cd34e87055c5358018
Do you want to proceed with the proposed reshard plan (yes/no)? yes #输入yes
………………
Moving slot 996 from 10.0.18.147:7006 to 10.0.18.147:7004:
Moving slot 997 from 10.0.18.147:7006 to 10.0.18.147:7004:
Moving slot 998 from 10.0.18.147:7006 to 10.0.18.147:7004:
Moving slot 999 from 10.0.18.147:7006 to 10.0.18.147:7004:
查看集群信息:
#./bin/redis-cli -h 10.0.18.146 -p 7002 cluster nodes
5cbec92f52fbe9da7cd643cd34e87055c5358018 10.0.18.147:7006 master - 0 1476957466206 7 connected
37ea68d5cfd3953bde636656dd2250d5f6a7029d 10.0.18.147:7005 slave faee6763e5f591d9d63df8d841041255ae7992f3 0 1476957469212 6 connected
faee6763e5f591d9d63df8d841041255ae7992f3 10.0.18.146:7002 myself,master - 0 0 3 connected 5461-10922
c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b 10.0.18.147:7004 master - 0 1476957467206 8 connected 0-5460
4eeee08df0ee4ee0db34b39bf6922a24edb356d8 10.0.18.146:7003 slave c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b 0 1476957469211 8 connected
b3798ae7f13e4fca57e7a505eca0dae1f19ce4c3 10.0.18.145:7001 slave 2e2f563a1467c2515857d70d762c26b06faabbd4 0 1476957468209 2 connected
2e2f563a1467c2515857d70d762c26b06faabbd4 10.0.18.145:7000 master - 0 1476957470214 1 connected 10923-16383
现在可以删除10.0.18.147:7006这个master节点了,如下:
#./bin/redis-trib.rb del-node 10.0.18.147:7006 5cbec92f52fbe9da7cd643cd34e87055c5358018
>>> Removing node 5cbec92f52fbe9da7cd643cd34e87055c5358018 from cluster 10.0.18.147:7006
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.
/usr/lib/ruby/gems/1.8/gems/redis-3.3.1/lib/redis/client.rb:121:in `call': ERR unknown command 'shutdown' (Redis::CommandError)
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.1/lib/redis.rb:306:in `shutdown'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.1/lib/redis/client.rb:293:in `with_reconnect'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.1/lib/redis.rb:304:in `shutdown'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.1/lib/redis.rb:58:in `synchronize'
from /usr/lib/ruby/1.8/monitor.rb:242:in `mon_synchronize'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.1/lib/redis.rb:58:in `synchronize'
from /usr/lib/ruby/gems/1.8/gems/redis-3.3.1/lib/redis.rb:303:in `shutdown'
from ./bin/redis-trib.rb:1389:in `delnode_cluster_cmd'
from ./bin/redis-trib.rb:1695:in `send'
from ./bin/redis-trib.rb:1695
删除之后再次查看节点信息:
#./bin/redis-cli -h 10.0.18.146 -p 7002 cluster nodes
37ea68d5cfd3953bde636656dd2250d5f6a7029d 10.0.18.147:7005 slave faee6763e5f591d9d63df8d841041255ae7992f3 0 1476957619621 6 connected
faee6763e5f591d9d63df8d841041255ae7992f3 10.0.18.146:7002 myself,master - 0 0 3 connected 5461-10922
c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b 10.0.18.147:7004 master - 0 1476957618620 8 connected 0-5460
4eeee08df0ee4ee0db34b39bf6922a24edb356d8 10.0.18.146:7003 slave c1ea9a2adaa3f9790ccf29227293c9bafc6efb7b 0 1476957619621 8 connected
b3798ae7f13e4fca57e7a505eca0dae1f19ce4c3 10.0.18.145:7001 slave 2e2f563a1467c2515857d70d762c26b06faabbd4 0 1476957616615 2 connected
2e2f563a1467c2515857d70d762c26b06faabbd4 10.0.18.145:7000 master - 0 1476957618620 1 connected 10923-16383
可以看到10.0.18.147:7006这个master节点已经不存在了!
|
|
|
|
|
|
|