Databases 7 min read

Step-by-Step Guide to Building and Managing a Redis Cluster

This article provides a detailed, step‑by‑step tutorial on building a six‑node Redis cluster on a single Linux machine, covering directory setup, configuration files, Ruby‑based cluster tools, instance startup, cluster creation, verification, online scaling, slot rebalancing, and using Redis for session sharing.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Step-by-Step Guide to Building and Managing a Redis Cluster

Introduction: To set up a minimal Redis cluster you need six nodes (three masters and three slaves) on a single Linux VM, each running a separate Redis instance on different ports.

Step 1: Create separate directories for each instance.

Step 2: Copy and modify six redis.conf files, ensuring unique ports, data directories, AOF enabled, cluster mode and daemonize.

Step 3: Install Ruby and the redis gem to use the redis-trib.rb script for cluster management.

Step 4: Start all six Redis instances.

Step 5: Create the cluster with the command:

[root@mydream121 bin]# ./redis-trib.rb create --replicas 1 192.168.99.121:8001 192.168.99.121:8002 192.168.99.121:8003 192.168.99.121:8004 192.168.99.121:8005 192.168.99.121:8006

Explain that --replicas 1 creates a 1:1 master‑slave ratio, and slots are distributed among masters.

Step 6: Verify the cluster using redis-cli cluster info and redis-cli cluster nodes .

Additional operations: Demonstrate online horizontal scaling by adding two new instances (8007, 8008), using redis-trib.rb add-node and redis-trib.rb reshard to assign slots, and configuring the new node as a replica.

Finally, note that Redis can be used for session sharing across web servers, with existing plugins such as tomcat‑redis‑session‑manager.

backendDatabaseRedisLinuxClusterRuby
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.