redis叢集給新新增的節點分配槽道的操作
一、準備好redis叢集如下:
10.211.55.5:8001> cluster nodes da23623c6e915de5256bb2252cd1057d4f29e558 10.211.55.5:8003 master - 0 1538583619331 0 connected
3f3049540ba60e30080847e78ccf832f94961da2 10.211.55.5:8004 slave 6f4a31fc322725fc4ed453a588f344fed4f261bf 0 1538583620339 2 connected
6f4a31fc322725fc4ed453a588f344fed4f261bf 10.211.55.5:8001 myself,master - 0 0 2 connected 5461-10922
8ce851252f32fcab268e77d3b3ed976d57d2f498 10.211.55.5:8000 master - 0 1538583622352 1 connected 0-5460
da7d09090520a0e6287ea12fe7f48225d6665f68 10.211.55.5:8002 master - 0 1538583621346 3 connected 10923-16383
10.211.55.5:8001>
二、給8003節點分配50個槽道
執行命令如下,8004是叢集中的任意一個節點
[[email protected] src]# ./redis-trib.rb reshard 10.211.55.5:8004
Performing Cluster Check (using node 10.211.55.5:8004)
S: 3f3049540ba60e30080847e78ccf832f94961da2 10.211.55.5:8004
slots: (0 slots) slave
replicates 6f4a31fc322725fc4ed453a588f344fed4f261bf
M: da7d09090520a0e6287ea12fe7f48225d6665f68 10.211.55.5:8002
slots:10923-16383 (5461 slots) master
0 additional replica(s)
M: da23623c6e915de5256bb2252cd1057d4f29e558 10.211.55.5:8003
slots: (0 slots) master
0 additional replica(s)
M: 6f4a31fc322725fc4ed453a588f344fed4f261bf 10.211.55.5:8001
slots:5461-10922 (5462 slots) master
1 additional replica(s)
M: 8ce851252f32fcab268e77d3b3ed976d57d2f498 10.211.55.5:8000
slots:0-5460 (5461 slots) master
0 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)?50
What is the receiving node ID? da23623c6e915de5256bb2252cd1057d4f29e558
*** The specified node is not known or not a master, please retry.
What is the receiving node ID? da23623c6e915de5256bb2252cd1057d4f29e558
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:all
這裡使用all將會自動計算從所有主節點平均獲取槽道移動
使用done,注意輸入master節點的id,從cluster nodes中貼上
回車後,以下輸入yes,就分配完成後
Do you want to proceed with the proposed reshard plan (yes/no)?
yes
檢視分配後的結果:
10.211.55.5:8001> cluster nodes
da23623c6e915de5256bb2252cd1057d4f29e558 10.211.55.5:8003 master - 0 1538584291512 5 connected 0-15 5461-5477 10923-10938
3f3049540ba60e30080847e78ccf832f94961da2 10.211.55.5:8004 slave 6f4a31fc322725fc4ed453a588f344fed4f261bf 0 1538584288492 2 connected
6f4a31fc322725fc4ed453a588f344fed4f261bf 10.211.55.5:8001 myself,master - 0 0 2 connected 5478-10922
8ce851252f32fcab268e77d3b3ed976d57d2f498 10.211.55.5:8000 master - 0 1538584293523 1 connected 16-5460
da7d09090520a0e6287ea12fe7f48225d6665f68 10.211.55.5:8002 master - 0 1538584292518 3 connected 10939-16383
重新分配槽道,不能重新操作有資料的槽道,空槽道可以reshard,有數 據的需要手動遷移資料後在遷移槽道