Redistribute the hash:
ip:port is the ip and port of any node in the current redis cluster (recommended learning: Redis video tutorial)
redis-cli --cluster reshard ip:port
The operation is as shown:
There are two allocation hash slots Methods:
1. Take out an appropriate number of hash slots on other nodes and allocate them to the target node
2. Take out a specified number of hash slots on the specified node and allocate them to Target node
As shown above, the number of hash slots of the master node with port number 7005 is 0, and 300 hash slots are allocated to it:
How many slots do you want to move (from 1 to 16384)? Enter here the number of hash slots you want to allocate (as shown above)
What is the receiving node ID ? Enter here to allocate the number of hash slots specified in the previous step to that node, enter the node id (as shown above)
Here is to let You choose the source of hash slots that need to be allocated. There are two options:
1. Enter all. The hash slots that need to be allocated to the target node come from other master nodes of the current cluster (each node takes The number of outputs is automatically determined by the cluster. The above picture is done in this way!)
Effect (the original number of master node hash slots on port 7005 is 0):
2. Enter the ID of a node. In this case, all the hash slots that need to be allocated to the target node will be borne by the node (you can enter multiple node IDs, press Enter to separate, enter done to end ).
Use the second method to allocate hash slots:
Now the node hash slot of port 7005 is 300, use the second method to allocate it, and then add 100, take the hash slot of 100 on the node with port 7002
View the effect:
The current master node of port 7005 has 400 hash slots!
For more Redis-related technical articles, please visit the Redis Getting Started Tutorial column to learn!
The above is the detailed content of How does redis cluster allocate hash slots. For more information, please follow other related articles on the PHP Chinese website!