How to Reshard a Redis Cluster: Step-by-Step Guide
This guide explains how to reshard a Redis cluster by moving hash slots between nodes, detailing each command-line step, required inputs, and verification procedures to ensure balanced slot distribution across the cluster.
Resharding moves slots between nodes in a Redis cluster and is the basis for adding or removing nodes.
Steps
Run the redis-trib.rb reshard <node_ip:port> command, specifying a node address so the tool can discover the cluster.
Set the number of slots to move.
Specify the ID of the node that will receive the slots.
Specify the ID of the node from which the slots will be moved.
Example
Connecting to node 127.0.0.1:7000…
… # redis-trib.rb reshard 127.0.0.1:7000 …
Prompt: How many slots do you want to move (from 1 to 16384)?
Enter 100.
Prompt: What is the receiving node ID?
Enter the target node ID, e.g., 9b569ab95eb442550299dab16aef6a5c5db295cf.
Prompt: Please enter all the source node IDs. Type 'all' to use all nodes or specify individual IDs, ending with 'done'.
Enter all for testing.
Resharding plan is displayed, e.g., “Moving slot 0 from e0f4fd7576a019b812bd6090d02cec5f975c2bbe …”. Confirm with yes to start.
During execution you will see lines such as:
Moving slot 0 from 127.0.0.1:7000 to 127.0.0.1:7001: Moving slot 1 from 127.0.0.1:7000 to 127.0.0.1:7001:After completion, run a check: redis-trib.rb check 127.0.0.1:7000 The check confirms that all 16384 slots are covered and shows the slot distribution among the three masters, with node 2 holding slightly more slots.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
