Manual Setup of a Redis Cluster on macOS
This article provides a step‑by‑step guide for manually building a six‑node Redis cluster on macOS, detailing environment setup, configuration changes, node startup, slot allocation, and converting master nodes to slaves, with screenshots and command examples.
Preface
The previous article explained the working principle of Redis clusters; this article demonstrates how to manually build a Redis cluster. Readers are encouraged to review the previous article first for a clearer understanding of the installation process.
Environment and Version
Environment: macOS 10.14.6
Redis version: Redis-4.0.10
Final Goal
The cluster will consist of six nodes: three masters and three slaves.
Ports 7000‑7002 will serve as master nodes.
Ports 7003‑7005 will serve as slave nodes.
Master‑slave mapping: 7000 ↔ 7003, 7001 ↔ 7004, 7002 ↔ 7005.
Cluster Build and Verification
Create a directory and within it create six sub‑folders to hold the cluster files.
Modify the redis.conf file of the extracted Redis distribution.
Copy the prepared Redis directory into each of the six node folders, adjust the port number in each, and start the instances (example shown for node 1).
After all six nodes start successfully, the following screenshot is displayed.
At this point the six nodes are up; the next steps are: (1) connect the nodes together, (2) assign the 16384 hash slots to the three master nodes, and (3) change three nodes to slave role (by default all nodes start as masters).
Connect the nodes (operation performed on node 1).
Assign slots, selecting ports 7000‑7002 as masters and 7003‑7005 as slaves.
Note: Do not use redis-cli to log in for this step, otherwise an error will occur.
After slot allocation, the cluster reports cluster_state:ok, indicating the Redis cluster is operational.
Checking the slot distribution confirms that all 16384 slots have been allocated to the nodes on ports 7000, 7001, and 7002 as expected.
Convert nodes 7003, 7004, and 7005 to slave role: 7003 becomes a slave of 7000, 7004 a slave of 7001, and 7005 a slave of 7002. Execute the commands shown in the screenshot.
After running the above commands, the cluster status appears as shown, confirming the expected master‑slave configuration.
Thus the three nodes on ports 7000‑7002 are masters, and the three nodes on ports 7003‑7005 are slaves, as intended.
Summary
Through this hands‑on demonstration we verified the conclusions of the previous article; future posts will continue to use practical experiments for validation.
If you encounter any issues while building your own cluster, you can contact the author via the QR code provided.
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.
Full-Stack Internet Architecture
Introducing full-stack Internet architecture technologies centered on Java
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.
