How to Add Master or Slave Nodes to a Redis Cluster Step‑by‑Step
This guide walks you through the complete process of adding a new master or slave node to an existing Redis cluster, covering configuration, startup, cluster integration, verification, and slot migration to ensure the new node operates correctly.
Add a Master Node
1. Create a new directory (e.g., 7006) under the existing cluster directory and copy the redis.conf from an existing node (e.g., 7005) into it.
2. Edit 7006/redis.conf to change the port to 7006, then start the server with redis-server redis.conf.
3. Verify the process is running, for example with ps -ef | grep redis, and confirm that the instance on port 7006 started successfully.
4. Add the new node to the cluster using redis-trib.rb add-node 127.0.0.1:7006 127.0.0.1:7000. The tool will report that the node was added correctly.
5. Check the cluster status with redis-trib.rb check 127.0.0.1:7000. The new master will appear with zero slots.
6. Move a portion of slots to the new master using the cluster resharding procedure, allowing it to serve data.
Add a Slave Node
1. Configure and start a new Redis instance in the same way as for a master.
2. Connect to the new instance with redis-cli -c -p 7006 and view the cluster nodes.
3. Choose an existing master (e.g., the node on port 7002), copy its node ID, and run cluster replicate 9b569ab95eb442550299dab16aef6a5c5db295cf on the new node.
Note: A slave can only replicate a master, not another slave.
4. Verify the replication relationship by running cluster nodes again; the new node will be listed as a replica of the chosen master.
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.
