Dynamic scaling of redis cluster cluster -- delete master and slave nodes

Goal: remove a set of master-slave (50075008) from the cluster

After adding 50075008 primary and secondary service nodes in the previous section, the current cluster situation is as follows:

b3363a81c3c59d57143cd3323481259c044e66d2 192.168.8.196:5006@15006 slave 1b7aa419065c5477c0def9d5e25106963fbdda76 0 1573003356000 3 connected
1b7aa419065c5477c0def9d5e25106963fbdda76 192.168.8.196:5003@15003 master - 0 1573003352829 3 connected 11089-16383
fbf9f23ecf0fea399debf7db42c73fece04b98fd 192.168.8.196:5005@15005 slave b1b67d4e554e29605bdbe40deab6670a42dd8836 0 1573003356842 2 connected
b1b67d4e554e29605bdbe40deab6670a42dd8836 192.168.8.196:5002@15002 master - 0 1573003355000 2 connected 5628-10922
d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 192.168.8.196:5001@15001 master - 0 1573003354837 1 connected 166-5460
9dc870942555447543694e42e40061823ed91271 192.168.8.196:5004@15004 slave d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 0 1573003357846 1 connected
63aa476d990dfa9f5f40eeeaa0315e7f9948554d 192.168.8.196:5007@15007 master - 0 1573003356000 7 connected 0-165 5461-5627 10923-11088
d3a9de370962873d17f1124bcf9ac166cc6ba950 192.168.8.196:5008@15008 myself,slave 63aa476d990dfa9f5f40eeeaa0315e7f9948554d 0 1573003350000 0 connected
Serial number master node slave node
1 192.168.8.196:5001 192.168.8.196:5004
2 192.168.8.196:5002 192.168.8.196:5005
3 192.168.8.196:5003 192.168.8.196:5006
4 192.168.8.196:5007 192.168.8.196:5008

Start implementation:
1. Remove 192.168.8.196:5008 slave node first

redis-cli --cluster del-node 192.168.8.196:5008 d3a9de370962873d17f1124bcf9ac166cc6ba950

>> Removing node d3a9de370962873d17f1124bcf9ac166cc6ba950 from cluster 192.168.8.196:5008
>> Sending CLUSTER FORGET messages to the cluster...
>> SHUTDOWN the node.
>>

At this time, 192.168.8.196:5008 slave node has been deleted.

192.168.8.196:5001> cluster nodes
b3363a81c3c59d57143cd3323481259c044e66d2 192.168.8.196:5006@15006 slave 1b7aa419065c5477c0def9d5e25106963fbdda76 0 1573004309001 6 connected
9dc870942555447543694e42e40061823ed91271 192.168.8.196:5004@15004 slave d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 0 1573004310000 4 connected
1b7aa419065c5477c0def9d5e25106963fbdda76 192.168.8.196:5003@15003 master - 0 1573004311007 3 connected 11089-16383
b1b67d4e554e29605bdbe40deab6670a42dd8836 192.168.8.196:5002@15002 master - 0 1573004307000 2 connected 5628-10922
63aa476d990dfa9f5f40eeeaa0315e7f9948554d 192.168.8.196:5007@15007 master - 0 1573004307000 7 connected 0-165 5461-5627 10923-11088
fbf9f23ecf0fea399debf7db42c73fece04b98fd 192.168.8.196:5005@15005 slave b1b67d4e554e29605bdbe40deab6670a42dd8836 0 1573004310004 5 connected
d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 192.168.8.196:5001@15001 myself,master - 0 1573004308000 1 connected 166-5460
  1. For the 192.168.8.196:5007 master node, the partition on the 5007 is transferred to other nodes

    $ redis-cli --cluster reshard 192.168.8.196:5007

There will be a question and answer item

#Number of data slots to be moved
How many slots do you want to move (from 1 to 16384)? 500
#You need to accept the master node ID of the data slot. Here we fill in the master service node ID 5001
What is the receiving node ID? d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2
#Fill in data slot source node
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: 63aa476d990dfa9f5f40eeeaa0315e7f9948554d
Source node #2: done

After execution, the data slot on master 5007 has been transferred to master 5001. At this point, there are no data slots on the 5007.

b3363a81c3c59d57143cd3323481259c044e66d2 192.168.8.196:5006@15006 slave 1b7aa419065c5477c0def9d5e25106963fbdda76 0 1573004510000 6 connected
9dc870942555447543694e42e40061823ed91271 192.168.8.196:5004@15004 slave d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 0 1573004510589 8 connected
1b7aa419065c5477c0def9d5e25106963fbdda76 192.168.8.196:5003@15003 master - 0 1573004508000 3 connected 11089-16383
b1b67d4e554e29605bdbe40deab6670a42dd8836 192.168.8.196:5002@15002 master - 0 1573004510000 2 connected 5628-10922
63aa476d990dfa9f5f40eeeaa0315e7f9948554d 192.168.8.196:5007@15007 master - 0 1573004508000 7 connected
fbf9f23ecf0fea399debf7db42c73fece04b98fd 192.168.8.196:5005@15005 slave b1b67d4e554e29605bdbe40deab6670a42dd8836 0 1573004511594 5 connected
d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 192.168.8.196:5001@15001 myself,master - 0 1573004509000 8 connected 0-5627 10923-11088

3. In the last step, remove 192.168.8.196:5007

$ redis-cli --cluster del-node 192.168.8.196:5007 63aa476d990dfa9f5f40eeeaa0315e7f9948554d

>>> Removing node 63aa476d990dfa9f5f40eeeaa0315e7f9948554d from cluster 192.168.8.196:5007
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.

4.50075008 master-slave nodes have been removed and achieved success.

192.168.8.196:5001> cluster nodes
b3363a81c3c59d57143cd3323481259c044e66d2 192.168.8.196:5006@15006 slave 1b7aa419065c5477c0def9d5e25106963fbdda76 0 1573004592840 6 connected
9dc870942555447543694e42e40061823ed91271 192.168.8.196:5004@15004 slave d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 0 1573004591000 8 connected
1b7aa419065c5477c0def9d5e25106963fbdda76 192.168.8.196:5003@15003 master - 0 1573004591000 3 connected 11089-16383
b1b67d4e554e29605bdbe40deab6670a42dd8836 192.168.8.196:5002@15002 master - 0 1573004591838 2 connected 5628-10922
fbf9f23ecf0fea399debf7db42c73fece04b98fd 192.168.8.196:5005@15005 slave b1b67d4e554e29605bdbe40deab6670a42dd8836 0 1573004591000 5 connected
d1a4b1aa3e924a5917efc240cdb2e3ada39e01c2 192.168.8.196:5001@15001 myself,master - 0 1573004589000 8 connected 0-5627 10923-11088

Tags: Database Redis

Posted on Wed, 06 Nov 2019 12:59:54 -0800 by mtoynbee