溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Redis集群中刪除/修改節(jié)點(diǎn)(master、slave)(實(shí)驗(yàn))

發(fā)布時(shí)間:2020-07-01 08:34:34 來源:網(wǎng)絡(luò) 閱讀:8355 作者:張德帥ya 欄目:數(shù)據(jù)庫(kù)

刪除一個(gè)slave節(jié)點(diǎn):

? ? # redis-trib.rb del-node 192.168.2.202:6380 e4dc23dc67418bf66c6c63655110612cb9516aff

? ? ? ? ? ? ? ? ? ? ? ?// del-node ?host:port ?node-id

? ? ? ?>>> Removing node e4dc23dc67418bf66c6c63655110612cb9516aff from cluster 192.168.2.202:6380

? ? ? ?>>> Sending CLUSTER FORGET messages to the cluster...

? ? ? ? >>> SHUTDOWN the node.

? ? ? ??

查看集群節(jié)點(diǎn)信息:

? ? # redis-trib.rb check 192.168.2.100:6379 (確認(rèn)slave節(jié)點(diǎn)已經(jīng)刪除)

? ? ? ? >>> Performing Cluster Check (using node 192.168.2.100:6379)

? ? ? ? M: 098e7eb756b6047fde988ab3c0b7189e1724ecf5 192.168.2.100:6379

? ? ? ? ? ? slots:333-5460 (5128 slots) master

? ? ? ? ? ? 1 additional replica(s)

? ? ? ? S: 7119dec91b086ca8fe69f7878fa42b1accd75f0f 192.168.2.100:6380

? ? ? ? ? ? slots: (0 slots) slave

? ? ? ? ? ? replicates 5844b4272c39456b0fdf73e384ff8c479547de47


刪除一個(gè)master節(jié)點(diǎn)

? ? 先移除master身上的hash slot,再刪除master。

? ? 目前不能直接刪除slot,要把刪除的master的slot遷移到其他master節(jié)點(diǎn)上。

? ? ?

? ? # redis-trib.rb reshard 192.168.2.100:6379 ? ? ? //slot遷移到2.100上

? ? ? ? How many slots do you want to move (from 1 to 16384)? 1000 ??

? ? ? ? ? ? ? ? ? ? ? ? ? //遷移多少個(gè)slot?(要?jiǎng)h除的master節(jié)點(diǎn)上有多少個(gè)slot)

? ? ? ? What is the receiving node ID? 098e7eb756b6047fde988ab3c0b7189e1724ecf5

? ? ? ? ? ? ? ? ? ? ? ? //遷移到那個(gè)節(jié)點(diǎn)上,ID是多少?(slot遷移給誰,寫誰的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:8326ff0be199fa0d4db74f0ebcc58f27e65991b4

? ? ? ? ? ? ? ? ? ? ? ? //被刪除的master的ID

? ? ? ? Source node #2:done ? ? ? ? ? ? ? ? ? ? ?//表示結(jié)束

? ? ? ? ... ...

? ? ? ? Do you want to proceed with the proposed reshard plan (yes/no)? yes

? ? ? ? ? ? ? ? ? ? ? ? //是否滿意hash slot移動(dòng)計(jì)劃?


把要?jiǎng)h除的master移除集群:

? ? # redis-trib.rb del-node 192.168.2.100:6379 8326ff0be199fa0d4db74f0ebcc58f27e65991b4

? ? ? ? ? ? ? //集群中任意節(jié)點(diǎn)的IP:端口、要?jiǎng)h除的master的ID

? ??

更改slave節(jié)點(diǎn)隸屬的master:


? ? ? ? 當(dāng)前配置中,192.168.2.100:6380隸屬于192.168.2.200:6379

? ? ? ? 將192.168.2.100:6380的隸屬更改為192.168.2.100:6379

? ? ? ??

? ? ? ? 1、登錄方式指定要更改隸屬關(guān)系的IP、端口

? ? ? ? 2、更改隸屬關(guān)系時(shí),直接指定新的master節(jié)點(diǎn)的ID

? ? ? ??

? ? # redis-cli -c -h 192.168.2.100 -p 6380

? ? ? ? > cluster nodes

? ? ? ? 5844b4272c39456b0fdf73e384ff8c479547de47 192.168.2.200:6379 master - 0 1527165062499 3 ?connected 5795-10922

? ? ? ? 2faf68564a70372cfc06c1afff197019cc6a39f3 192.168.2.201:6380 slave ? ? ? 3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69 0 1527165063511 6 connected

? ? ? ? 098e7eb756b6047fde988ab3c0b7189e1724ecf5 192.168.2.100:6379 master - 0 1527165060482 10 connected 0-5794 10923-11255

? ? ? ? 227f51028bbe827f27b4e40ed7a08fcc7d8df969 192.168.2.200:6380 slave ? 098e7eb756b6047fde988ab3c0b7189e1724ecf5 0 1527165059474 10 connected

? ? ? ? 7119dec91b086ca8fe69f7878fa42b1accd75f0f 192.168.2.100:6380 myself,slave ? ?5844b4272c39456b0fdf73e384ff8c479547de47 0 0 2 connected

? ? ? ? 3ff3a74f9dc41f8bc635ab845ad76bf77ffb0f69 192.168.2.201:6379 master - 0 1527165058465 5 ? ? connected 11256-16383

? ? ? ? 192.168.2.100:6380> ?

? ? ? ? 192.168.2.100:6380> cluster replicate 098e7eb756b6047fde988ab3c0b7189e1724ecf5

? ? ? ? OK ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI