hydd的Linux筆記Day64
Day64
建立叢集
叢集環境
環境拓撲
IP規劃
建立叢集
部署管理主機
可以部署在任意一臺redis伺服器上或者單獨部署
步驟如下:
-
部署ruby簡本執行環境
[root@mgm57 ~]#yum -y install rubygems [root@mgm57 ~]# which gem /usr/bin/gem [root@mgm57 ~]# ls *.gem redis-3.2.1.gem [root@mgm57 ~]# [root@mgm57 ~]# gem install redis-3.2.1.gem Successfully installed redis-3.2.1 Parsing documentation for redis-3.2.1 Installing ri documentation for redis-3.2.1 1 gem installed [root@mgm57 ~]#
-
建立管理叢集指令碼redis-trib.rb
[root@mgm57 ~]#mkdir /root/bin //建立命令檢索目錄
[root@mgm57 ~]#tar -zxvf redis-4.0.8.tar.gz
[root@mgm57 ~]#cd redis-4.0.8/src/
[root@mgm57 ~]#cp redis-trib.rb /root/bin/ //建立管理叢集指令碼
[root@mgm57 ~]#chmod +x /root/bin/redis-trib.rb
[root@mgm57 ~]#redis-trib.rb help //檢視命令幫助
建立叢集
配置6臺redis伺服器
啟用叢集功能(具體操作請看上一天)
設定服務資訊(6臺主機都要設定,下面以51主機為例)
[root@redisA ~]# /etc/init.d/redis_6379 stop //停止redis服務
Stopping ...
Waiting for Redis to shutdown ...
Redis stopped
[root@redisA ~]# vim /etc/redis/6379.conf //修改配置檔案
bind 192.168.4.51 //修改ip
port 6351 //修改埠(可選配置)
cluster-enabled yes //啟用叢集功能
cluster-config-file nodes-6379.conf //儲存叢集資訊的配置檔案
cluster-node-timeout 5000 //叢集節點通訊超時時間
:wq
[root@redisA ~]# rm -rf /var/lib/redis/6379/* //清空資料
[root@redisA ~]# vim +43 /etc/init.d/redis_6379
$CLIEXEC -h 192.168.4.51 -p 6351 shutdown
:wq
[root@redisA ~]# /etc/init.d/redis_6379 start
Starting Redis server...
[root@redisA ~]# netstat -utnlp | grep redis-server
tcp 0 0 192.168.4.51:6351 0.0.0.0:* LISTEN 21201/redis-server
tcp 0 0 192.168.4.51:16351 0.0.0.0:* LISTEN 21201/redis-server
在管理主機mgm57,建立叢集
[root@mgm57 ~]# redis-trib.rb create --replicas 1 \
> 192.168.4.51:6351 192.168.4.52:6352 192.168.4.53:6353 \
> 192.168.4.54:6354 192.168.4.55:6355 192.168.4.56:6356
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.4.51:6351
192.168.4.52:6352
192.168.4.53:6353
Adding replica 192.168.4.55:6355 to 192.168.4.51:6351
Adding replica 192.168.4.56:6356 to 192.168.4.52:6352
Adding replica 192.168.4.54:6354 to 192.168.4.53:6353
M: d9f8fe6d6d9dd391be8e7904501db1535e4d17cb 192.168.4.51:6351
slots:0-5460 (5461 slots) master
M: 324e05df3f143ef97e50d09be0328a695e655986 192.168.4.52:6352
slots:5461-10922 (5462 slots) master
M: 9e44139cffb8ebd7ed746aabbf4bcea9bf207645 192.168.4.53:6353
slots:10923-16383 (5461 slots) master
S: d9634ba0aa5c1a07193da4a013da6051c1515922 192.168.4.54:6354
replicates 9e44139cffb8ebd7ed746aabbf4bcea9bf207645
S: 2d343a9df48f6f6e207949e980ef498466a44dad 192.168.4.55:6355
replicates d9f8fe6d6d9dd391be8e7904501db1535e4d17cb
S: 894dd0008053f6fb65e9e4a36b755d9351607500 192.168.4.56:6356
replicates 324e05df3f143ef97e50d09be0328a695e655986
Can I set the above configuration? (type 'yes' to accept): yes //同意以上配置
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join...
>>> Performing Cluster Check (using node 192.168.4.51:6351)
M: d9f8fe6d6d9dd391be8e7904501db1535e4d17cb 192.168.4.51:6351
slots:0-5460 (5461 slots) master
1 additional replica(s)
S: d9634ba0aa5c1a07193da4a013da6051c1515922 192.168.4.54:6354
slots: (0 slots) slave
replicates 9e44139cffb8ebd7ed746aabbf4bcea9bf207645
S: 894dd0008053f6fb65e9e4a36b755d9351607500 192.168.4.56:6356
slots: (0 slots) slave
replicates 324e05df3f143ef97e50d09be0328a695e655986
M: 324e05df3f143ef97e50d09be0328a695e655986 192.168.4.52:6352
slots:5461-10922 (5462 slots) master
1 additional replica(s)
M: 9e44139cffb8ebd7ed746aabbf4bcea9bf207645 192.168.4.53:6353
slots:10923-16383 (5461 slots) master
1 additional replica(s)
S: 2d343a9df48f6f6e207949e980ef498466a44dad 192.168.4.55:6355
slots: (0 slots) slave
replicates d9f8fe6d6d9dd391be8e7904501db1535e4d17cb
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered. //提示16384個槽分配完畢
[root@mgm57 ~]#
檢視叢集資訊
在管理主機上檢視
[root@mgm57 ~]# redis-trib.rb info 192.168.4.51:6351 //檢視叢集資訊
192.168.4.51:6351 (d9f8fe6d...) -> 0 keys | 5461 slots | 1 slaves.
192.168.4.52:6352 (324e05df...) -> 0 keys | 5462 slots | 1 slaves.
192.168.4.53:6353 (9e44139c...) -> 0 keys | 5461 slots | 1 slaves.
[OK] 0 keys in 3 masters.
0.00 keys per slot on average
在管理主機檢測叢集
[root@mgm57 ~]# redis-trib.rb check 192.168.4.51:6351 //檢測叢集
>>> Performing Cluster Check (using node 192.168.4.51:6351)
M: d9f8fe6d6d9dd391be8e7904501db1535e4d17cb 192.168.4.51:6351
slots:0-5460 (5461 slots) master
1 additional replica(s)
S: d9634ba0aa5c1a07193da4a013da6051c1515922 192.168.4.54:6354
slots: (0 slots) slave
replicates 9e44139cffb8ebd7ed746aabbf4bcea9bf207645
S: 894dd0008053f6fb65e9e4a36b755d9351607500 192.168.4.56:6356
slots: (0 slots) slave
replicates 324e05df3f143ef97e50d09be0328a695e655986
M: 324e05df3f143ef97e50d09be0328a695e655986 192.168.4.52:6352
slots:5461-10922 (5462 slots) master
1 additional replica(s)
M: 9e44139cffb8ebd7ed746aabbf4bcea9bf207645 192.168.4.53:6353
slots:10923-16383 (5461 slots) master
1 additional replica(s)
S: 2d343a9df48f6f6e207949e980ef498466a44dad 192.168.4.55:6355
slots: (0 slots) slave
replicates d9f8fe6d6d9dd391be8e7904501db1535e4d17cb
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
3)在任意一臺redis伺服器本機,檢視叢集資訊
[root@redisA ~]# redis-cli -h 192.168.4.51 -p 6351
192.168.4.51:6351> cluster info //檢視叢集資訊
cluster_state:ok
……
……
cluster_known_nodes:6
cluster_size:3
192.168.4.51:6351> cluster nodes //檢視叢集節點資訊
d9634ba0aa5c1a07193da4a013da6051c1515922 192.168.4.54:6354@16354 slave 9e44139cffb8ebd7ed746aabbf4bcea9bf207645 0 1561357552212 4 connected
894dd0008053f6fb65e9e4a36b755d9351607500 192.168.4.56:6356@16356 slave 324e05df3f143ef97e50d09be0328a695e655986 0 1561357554216 6 connected
d9f8fe6d6d9dd391be8e7904501db1535e4d17cb 192.168.4.51:6351@16351 myself,master - 0 1561357545000 1 connected 0-5460
324e05df3f143ef97e50d09be0328a695e655986 192.168.4.52:6352@16352 master - 0 1561357553214 2 connected 5461-10922
9e44139cffb8ebd7ed746aabbf4bcea9bf207645 192.168.4.53:6353@16353 master - 0 1561357554216 3 connected 10923-16383
2d343a9df48f6f6e207949e980ef498466a44dad 192.168.4.55:6355@16355 slave d9f8fe6d6d9dd391be8e7904501db1535e4d17cb 0 1561357553716 5 connected
192.168.4.51:6351>
訪問叢集
在客戶端可以連線叢集中任意一臺redis伺服器
命令:redis-cli -c -h ip地址 -p埠號
選項:-c叢集模式
1)在客戶端連線叢集中的任意一臺伺服器存取資料
[root@client50 ~]# redis-cli -c -h 192.168.4.51 -p 6351 //連線伺服器51
192.168.4.51:6351>
192.168.4.51:6351> set x 100 //儲存
-> Redirected to slot [16287] located at 192.168.4.53:6353 //提示儲存在53主機
OK
192.168.4.53:6353> keys *
1) "x"
192.168.4.53:6353>
192.168.4.53:6353> set y 200
OK
192.168.4.53:6353> keys *
1) "y"
2) "x"
192.168.4.53:6353> set z 300 //儲存
-> Redirected to slot [8157] located at 192.168.4.52:6352 //提示儲存在52主機
OK
192.168.4.52:6352> keys * //在52主機檢視資料 只有變數z
1) "z"
192.168.4.52:6352> get x
-> Redirected to slot [16287] located at 192.168.4.53:6353 //連線53主機獲取資料
"100"
192.168.4.53:6353> keys *
1) "y"
2) "x"
192.168.4.53:6353> get z
-> Redirected to slot [8157] located at 192.168.4.52:6352
"300"
192.168.4.52:6352> set i 400
-> Redirected to slot [15759] located at 192.168.4.53:6353
OK
192.168.4.53:6353> set j 500
-> Redirected to slot [3564] located at 192.168.4.51:6351
OK
192.168.4.51:6351>
管理叢集
測試叢集功能
故障切換測試
停止master 主機的redis服務
master當機後對應的slave自動被選舉為master
原master啟動後,會自動配置為當前master的slave
檢測叢集
在管理主機檢視
redis-trib.rb check 192.168.4.52:6352
redis-trib.rd info 192.168.4.52:6352
新增伺服器
新增master伺服器
部署新redis伺服器 ip為192.168.4.58
1)裝包,初始化,啟用叢集功能,重啟服務
]#yum -y install gcc
]#tar -zxvf redis-4.0.8.tar.gz
]#cd redis-4.0.8/
]#make
]#make install
]#./utils/install_server.sh
]# /etc/init.d/redis_6379 stop
vim /etc/redis/6379.conf
bind 192.168.4.58
port 6358
cluster-enabled yes //啟用叢集
cluster-config-file nodes-6379.conf //儲存叢集資訊檔案
cluster-node-timeout 5000
:wq
]# vim +43 /etc/init.d/redis_6379
$CLIEXEC -h 192.168.4.58 -p 6358 shutdown
:wq
]# /etc/init.d/redis_6379 start
]# netstat -utnlp | grep redis-server
tcp 0 0 192.168.4.58:6358 0.0.0.0:* LISTEN 21201/redis-server
tcp 0 0 192.168.4.58:16358 0.0.0.0:* LISTEN 21201/redis-server
新增master角色主機到叢集裡
1)在管理主機,新增master角色主機
[root@mgm57 ~]# redis-trib.rb add-node 192.168.4.58:6358 192.168.4.53:6353 //執行新增命令
>>> Adding node 192.168.4.58:6358 to cluster 192.168.4.53:6353
>>> Performing Cluster Check (using node 192.168.4.53:6353)
M: 9e44139cffb8ebd7ed746aabbf4bcea9bf207645 192.168.4.53:6353
slots:10923-16383 (5461 slots) master
1 additional replica(s)
S: d9634ba0aa5c1a07193da4a013da6051c1515922 192.168.4.54:6354
slots: (0 slots) slave
replicates 9e44139cffb8ebd7ed746aabbf4bcea9bf207645
M: 324e05df3f143ef97e50d09be0328a695e655986 192.168.4.52:6352
slots:5461-10922 (5462 slots) master
1 additional replica(s)
S: 894dd0008053f6fb65e9e4a36b755d9351607500 192.168.4.56:6356
slots: (0 slots) slave
replicates 324e05df3f143ef97e50d09be0328a695e655986
S: d9f8fe6d6d9dd391be8e7904501db1535e4d17cb 192.168.4.51:6351
slots: (0 slots) slave
replicates 2d343a9df48f6f6e207949e980ef498466a44dad
M: 2d343a9df48f6f6e207949e980ef498466a44dad 192.168.4.55:6355
slots:0-5460 (5461 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.
>>> Send CLUSTER MEET to node 192.168.4.58:6358 to make it join the cluster.
[OK] New node added correctly. //提示新增完成
2)在管理主機,檢視叢集新訊息
[root@mgm57 ~]# redis-trib.rb info 192.168.4.53:6353 //檢視叢集資訊
192.168.4.53:6353 (9e44139c...) -> 3 keys | 5461 slots | 1 slaves.
192.168.4.52:6352 (324e05df...) -> 2 keys | 5462 slots | 1 slaves.
192.168.4.58:6358 (4fe1fa46...) -> 0 keys | 0 slots | 0 slaves. //主伺服器58
192.168.4.55:6355 (2d343a9d...) -> 3 keys | 5461 slots | 1 slaves.
[OK] 8 keys in 4 masters.
0.00 keys per slot on average.
3)在管理主機,檢測叢集
[root@mgm57 ~]# redis-trib.rb check 192.168.4.53:6353 //檢測叢集
>>> Performing Cluster Check (using node 192.168.4.53:6353)
M: 9e44139cffb8ebd7ed746aabbf4bcea9bf207645 192.168.4.53:6353
slots:10923-16383 (5461 slots) master
1 additional replica(s)
S: d9634ba0aa5c1a07193da4a013da6051c1515922 192.168.4.54:6354
slots: (0 slots) slave
replicates 9e44139cffb8ebd7ed746aabbf4bcea9bf207645
M: 324e05df3f143ef97e50d09be0328a695e655986 192.168.4.52:6352
slots:5461-10922 (5462 slots) master
1 additional replica(s)
S: 894dd0008053f6fb65e9e4a36b755d9351607500 192.168.4.56:6356
slots: (0 slots) slave
replicates 324e05df3f143ef97e50d09be0328a695e655986
M: 4fe1fa467ad237802021f5aac5f1d5b3e0db47ef 192.168.4.58:6358
slots: (0 slots) master //master伺服器58 ,沒有hash槽
0 additional replica(s)
S: d9f8fe6d6d9dd391be8e7904501db1535e4d17cb 192.168.4.51:6351
slots: (0 slots) slave
replicates 2d343a9df48f6f6e207949e980ef498466a44dad
M: 2d343a9df48f6f6e207949e980ef498466a44dad 192.168.4.55:6355
slots:0-5460 (5461 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.
4)在管理主機,重新分配hash槽
[root@mgm57 ~]# redis-trib.rb reshard 192.168.4.53:6353
How many slots do you want to move (from 1 to 16384)?4096 //拿出4096個hash 槽給主機192.168.4.58
What is the receiving node ID? c5e0da48f335c46a2ec199faa99b830f537dd8a0 //主機192.168.4.58的id值
Source node #1:all //從當前所有master伺服器獲取hash槽
Do you want to proceed with the proposed reshard plan (yes/no)?yes //同意以上配置
...
Moving slot 12283 from 192.168.4.53:6353 to 192.168.4.58:6358:
Moving slot 12284 from 192.168.4.53:6353 to 192.168.4.58:6358:
Moving slot 12285 from 192.168.4.53:6353 to 192.168.4.58:6358:
Moving slot 12286 from 192.168.4.53:6353 to 192.168.4.58:6358:
Moving slot 12287 from 192.168.4.53:6353 to 192.168.4.58:6358:
5)在管理主機,檢視叢集資訊
[root@mgm57 ~]# redis-trib.rb info 192.168.4.53:6353
192.168.4.53:6353 (9e44139c...) -> 2 keys | 4096 slots | 1 slaves.
192.168.4.52:6352 (324e05df...) -> 1 keys | 4096 slots | 1 slaves.
192.168.4.58:6358 (4fe1fa46...) -> 4 keys | 4096 slots | 0 slaves. //hash槽4096個
192.168.4.55:6355 (2d343a9d...) -> 1 keys | 4096 slots | 1 slaves.
[OK] 8 keys in 4 masters.
0.00 keys per slot on average.
新增slave角色主機到叢集裡
1)部署新的redis伺服器 192.168.4.59
]#yum -y install gcc
]#tar -zxvf redis-4.0.8.tar.gz
]#cd redis-4.0.8/
]#make
]#make install
]#./utils/install_server.sh
]# /etc/init.d/redis_6379 stop
vim /etc/redis/6379.conf
bind 192.168.4.59
port 6359
cluster-enabled yes //啟用叢集
cluster-config-file nodes-6379.conf //儲存叢集資訊檔案
cluster-node-timeout 5000
:wq
]# vim +43 /etc/init.d/redis_6379
$CLIEXEC -h 192.168.4.59 -p 6359 shutdown
:wq
]# /etc/init.d/redis_6379 start
]# netstat -utnlp | grep redis-server
tcp 0 0 192.168.4.59:6359 0.0.0.0:* LISTEN 21201/redis-server
tcp 0 0 192.168.4.59:16359 0.0.0.0:* LISTEN 21201/redis-server
2)在管理主機,新增slave角色主機
[root@mgm57 ~]# redis-trib.rb add-node --slave 192.168.4.59:6359 192.168.4.51:6351 //執行新增命令
>>> Adding node 192.168.4.59:6359 to cluster 192.168.4.51:6351
>>> Performing Cluster Check (using node 192.168.4.51:6351)
S: d9f8fe6d6d9dd391be8e7904501db1535e4d17cb 192.168.4.51:6351
slots: (0 slots) slave
replicates 2d343a9df48f6f6e207949e980ef498466a44dad
S: 894dd0008053f6fb65e9e4a36b755d9351607500 192.168.4.56:6356
slots: (0 slots) slave
replicates 324e05df3f143ef97e50d09be0328a695e655986
M: 2d343a9df48f6f6e207949e980ef498466a44dad 192.168.4.55:6355
slots:1365-5460 (4096 slots) master
1 additional replica(s)
M: 9e44139cffb8ebd7ed746aabbf4bcea9bf207645 192.168.4.53:6353
slots:12288-16383 (4096 slots) master
1 additional replica(s)
S: d9634ba0aa5c1a07193da4a013da6051c1515922 192.168.4.54:6354
slots: (0 slots) slave
replicates 9e44139cffb8ebd7ed746aabbf4bcea9bf207645
M: 324e05df3f143ef97e50d09be0328a695e655986 192.168.4.52:6352
slots:6827-10922 (4096 slots) master
1 additional replica(s)
M: 4fe1fa467ad237802021f5aac5f1d5b3e0db47ef 192.168.4.58:6358
slots:0-1364,5461-6826,10923-12287 (4096 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.
Automatically selected master 192.168.4.58:6358
>>> Send CLUSTER MEET to node 192.168.4.59:6359 to make it join the cluster.
Waiting for the cluster to join.
>>> Configure node as replica of 192.168.4.58:6358. //提示新增完成
[OK] New node added correctly.
3) 在管理主機,檢視叢集新訊息
[root@mgm57 ~]# redis-trib.rb info 192.168.4.51:6351 //檢視資訊
192.168.4.55:6355 (2d343a9d...) -> 3 keys | 4096 slots | 1 slaves.
192.168.4.53:6353 (9e44139c...) -> 3 keys | 4096 slots | 1 slaves.
192.168.4.52:6352 (324e05df...) -> 2 keys | 4096 slots | 1 slaves.
192.168.4.58:6358 (4fe1fa46...) -> 5 keys | 4096 slots | 1 slaves. //有1個從伺服器
[OK] 13 keys in 4 masters.
0.00 keys per slot on average.
4)在管理主機,檢測叢集
[root@mgm57 ~]# redis-trib.rb check 192.168.4.53:6353 //檢測叢集
[root@mgm57 ~]# redis-trib.rb check 192.168.4.51:6351
>>> Performing Cluster Check (using node 192.168.4.51:6351)
S: d9f8fe6d6d9dd391be8e7904501db1535e4d17cb 192.168.4.51:6351
slots: (0 slots) slave
replicates 2d343a9df48f6f6e207949e980ef498466a44dad
S: 7f3fa4f20c8c516d5b412ecc22550ed8e7bb8d7a 192.168.4.59:6359 //從伺服器
slots: (0 slots) slave
replicates 4fe1fa467ad237802021f5aac5f1d5b3e0db47ef //58主機的id值
S: 894dd0008053f6fb65e9e4a36b755d9351607500 192.168.4.56:6356
slots: (0 slots) slave
replicates 324e05df3f143ef97e50d09be0328a695e655986
M: 2d343a9df48f6f6e207949e980ef498466a44dad 192.168.4.55:6355
slots:1365-5460 (4096 slots) master
1 additional replica(s)
M: 9e44139cffb8ebd7ed746aabbf4bcea9bf207645 192.168.4.53:6353
slots:12288-16383 (4096 slots) master
1 additional replica(s)
S: d9634ba0aa5c1a07193da4a013da6051c1515922 192.168.4.54:6354
slots: (0 slots) slave
replicates 9e44139cffb8ebd7ed746aabbf4bcea9bf207645
M: 324e05df3f143ef97e50d09be0328a695e655986 192.168.4.52:6352
slots:6827-10922 (4096 slots) master
1 additional replica(s)
M: 4fe1fa467ad237802021f5aac5f1d5b3e0db47ef 192.168.4.58:6358 //主伺服器
slots:0-1364,5461-6826,10923-12287 (4096 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.
5)在客戶端,訪問從伺服器59,檢視資料
[root@host50 ~]# redis-cli -c -h 192.168.4.59 -p 6359
192.168.4.59:6359> keys * //自動同步主伺服器58的資料
1) "name"
2) "name2"
3) "age"
4) "y"
5) "shcool5"
192.168.4.59:6359>
移除伺服器
把slave伺服器移除叢集
1)在管理主機,移除slave伺服器,從伺服器沒有槽,直接移除即可。
[root@mgm57 ~]# redis-trib.rb del-node 192.168.4.51:6351 f6649ea99b2f01faca26217691222c17a3854381 //執行移除命令
>>> Removing node f6649ea99b2f01faca26217691222c17a3854381
from cluster 192.168.4.57:6351
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node. //停止移除服務的Redis服務
2)在管理主機,檢視叢集資訊
[root@mgm57 ~]# redis-trib.rb info 192.168.4.51:6351
192.168.4.55:6355 (2d343a9d...) -> 3 keys | 4096 slots | 1 slaves.
192.168.4.53:6353 (9e44139c...) -> 3 keys | 4096 slots | 1 slaves.
192.168.4.52:6352 (324e05df...) -> 2 keys | 4096 slots | 1 slaves.
192.168.4.58:6358 (4fe1fa46...) -> 5 keys | 4096 slots | 0 slaves.//58主機,沒有從伺服器
[OK] 13 keys in 4 masters.
0.00 keys per slot on average.
1)在管理主機,先刪除master伺服器佔用的hash槽
[root@mgm57 ~]# redis-trib.rb reshard 192.168.4.53:6353
How many slots do you want to move (from 1 to 16384)?4096 //移除4096個數槽
What is the receiving node ID? bc5c4e082a5a3391b634cf433a6486c867cfc44b
//要移動給誰的id即目標主機(這裡可以隨機寫一個master的ID)
Source node #1: c5e0da48f335c46a2ec199faa99b830f537dd8a0
//從誰那移動即源主機(這裡寫4.58的ID)
Source node #2:done //設定完畢
...
Moving slot 12282 from c5e0da48f335c46a2ec199faa99b830f537dd8a0
Moving slot 12283 from c5e0da48f335c46a2ec199faa99b830f537dd8a0
Moving slot 12284 from c5e0da48f335c46a2ec199faa99b830f537dd8a0
Moving slot 12285 from c5e0da48f335c46a2ec199faa99b830f537dd8a0
Moving slot 12286 from c5e0da48f335c46a2ec199faa99b830f537dd8a0
Moving slot 12287 from c5e0da48f335c46a2ec199faa99b830f537dd8a0
Do you want to proceed with the proposed reshard plan (yes/no)?yes //提交
...
Moving slot 12282 from 192.168.4.58:6358 to 192.168.4.53:6353:
Moving slot 12283 from 192.168.4.58:6358 to 192.168.4.53:6353:
Moving slot 12284 from 192.168.4.58:6358 to 192.168.4.53:6353:
Moving slot 12285 from 192.168.4.58:6358 to 192.168.4.53:6353:
Moving slot 12286 from 192.168.4.58:6358 to 192.168.4.53:6353:
Moving slot 12287 from 192.168.4.58:6358 to 192.168.4.53:6353:
2)在管理主機,檢視叢集資訊
[root@mgm57 ~]# redis-trib.rb info 192.168.4.51:6351
192.168.4.55:6355 (2d343a9d...) -> 3 keys | 4096 slots | 1 slaves.
192.168.4.53:6353 (9e44139c...) -> 3 keys | 4096 slots | 1 slaves.
192.168.4.52:6352 (324e05df...) -> 2 keys | 4096 slots | 1 slaves.
192.168.4.58:6358 (4fe1fa46...) -> 0 keys | 0 slots | 0 slaves. //零個槽
[OK] 13 keys in 4 masters.
0.00 keys per slot on average.
3)在管理主機,移除master主機
[root@mgm57 ~]# redis-trib.rb del-node 192.168.4.53:6353 \
c5e0da48f335c46a2ec199faa99b830f537dd8a0 //刪除誰+刪除的id
>>> Removing node e081313ec843655d9bc5a17f3bed3de1dccb1d2b from cluster 192.168.4.51:6351
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.
4)在管理主機,檢視叢集資訊
[root@mgm57 ~]# redis-trib.rb info 192.168.4.51:6351
192.168.4.55:6355 (2d343a9d...) -> 3 keys | 4096 slots | 1 slaves.
192.168.4.53:6353 (9e44139c...) -> 3 keys | 4096 slots | 1 slaves.
192.168.4.52:6352 (324e05df...) -> 2 keys | 4096 slots | 1 slaves.
[OK] 13 keys in 3 masters. //主伺服器個數3臺,沒有58
0.00 keys per slot on average.
-node 192.168.4.53:6353 \
c5e0da48f335c46a2ec199faa99b830f537dd8a0 //刪除誰+刪除的id
Removing node e081313ec843655d9bc5a17f3bed3de1dccb1d2b from cluster 192.168.4.51:6351
Sending CLUSTER FORGET messages to the cluster…
SHUTDOWN the node.
4)在管理主機,檢視叢集資訊
[root@mgm57 ~]# redis-trib.rb info 192.168.4.51:6351
192.168.4.55:6355 (2d343a9d…) -> 3 keys | 4096 slots | 1 slaves.
192.168.4.53:6353 (9e44139c…) -> 3 keys | 4096 slots | 1 slaves.
192.168.4.52:6352 (324e05df…) -> 2 keys | 4096 slots | 1 slaves.
[OK] 13 keys in 3 masters. //主伺服器個數3臺,沒有58
0.00 keys per slot on average.
相關文章
- hydd的Linux筆記Day32Linux筆記
- Linux指令記不住的筆記Linux筆記
- Linux筆記Linux筆記
- 超有用的linux筆記Linux筆記
- Linux 命令筆記Linux筆記
- linux筆記2Linux筆記
- 【Linux】使用筆記Linux筆記
- linux筆記1Linux筆記
- Linux命令筆記Linux筆記
- Linux Hook 筆記LinuxHook筆記
- 初學linux的fork筆記Linux筆記
- linux入門筆記Linux筆記
- Linux命令列筆記Linux命令列筆記
- Linux筆記 篇(二)Linux筆記
- linux ipc namespace筆記Linuxnamespace筆記
- 筆記linux_06筆記Linux
- 筆記Linux_02筆記Linux
- 筆記Linux_01筆記Linux
- 筆記Linux_05筆記Linux
- 筆記linux_04筆記Linux
- Linux學習筆記Linux筆記
- Linux/Unix筆記本Linux筆記
- Linux fping 筆記Linux筆記
- Linux 核心配置筆記Linux筆記
- Linux 學習筆記Linux筆記
- Linux與DNS的學習筆記LinuxDNS筆記
- 【i春秋】linux常用的命令(筆記)Linux筆記
- Linux 筆記分享三:Linux 命令Linux筆記
- Linux 效能優化筆記Linux優化筆記
- Linux 學習筆記--程式Linux筆記
- Linux系統管理筆記Linux筆記
- Linux awk基礎筆記Linux筆記
- Linux筆記 -- 暫未分類Linux筆記
- Linux 命令使用筆記【vmstat】Linux筆記
- linux下vi使用筆記Linux筆記
- linux學習筆記一Linux筆記
- linux學習筆記二Linux筆記
- Linux私房菜筆記01Linux筆記