The previous blog post completed the construction of the redis cluster: click here
And the addition of nodes in the redis cluster means expansion: Click here
This blog post writes about how to delete nodes in the redis cluster (based on the previous blog post). The 111.111.111.111 in the blog post is replaced by the actual IP.
delete slave node
Here I want to delete the one master and one slave node added in the last expansion, first delete the slave node 6378
docker exec into the container 6377, use the check command to check the cluster status
docker exec -it redis-node7 /bin/bash
redis-cli --cluster check 111.111.111.111:6371
Get the 6378 node id in the red box (use your actual id), and then execute the command to delete the slave node
redis-cli --cluster del-node 111.111.111.111:6378 2ee73af85faf7708061ab4ffdb80a2845257ab5a
After the deletion is successful, use the check command to check the cluster status, and you will find that there is no slave node 6378
Reassign slots
redis-cli --cluster reshard 111.111.111.111:6371
Here is still 4096 obtained by dividing 16384 by 4
The next question is who will receive these slots, here I will directly assign these slots to the 6374 master node (6374 is the master node here, and 6374 may be the slave node in yours, see clearly before operating), so enter 6374 ID of the master node
Then ask you which node to delete, here enter the ID of the 6377 node, enter #2 after pressing enter, enter done and press enter to end
During the allocation process, ask again whether to continue, enter yes and press Enter, and wait for the allocation to complete.
Here, all the slots of the 6377 node have been assigned to the 6374 master node, and the check command is used again to check the cluster status
It can be seen that there are still four master nodes, but the 6377 master nodes have no slots
Delete 6387 master nodes
redis-cli --cluster del-node 111.111.111.111:6377 fdb615eb6c86ec8246739112b6cc89679b37f58b
Check the cluster situation again, it has become three masters and three slaves