Smart Male IT Programer Working on Desktop Computer. Software Development / Code Writing / Website Design / Database Architecture. Technical Department Office.
Image: Gorodenkoff/Adobe Stock

Redis is an open-source, in-memory database that offers plenty of features and more than enough performance to power your enterprise-level app or service. Recently, I wrote about deploying Redis on a single server. Although a single server will serve your project well, there’s a good chance you’re going to want to add the level of fail-over that comes along with clustering Redis. And that’s exactly what I’m going to show you.

With a Redis cluster, you gain high performance, asynchronous replication and linear scaling for up to 1,000 nodes.

SEE: Hiring Kit: Database engineer (TechRepublic Premium)

To properly deploy a Redis cluster, the recommended setup is six nodes with three serving as controllers. We’ll set up such a cluster with the following layout:

  • Controller 1:
  • Controller 2:
  • Controller 3:
  • Node 1:
  • Node 2:
  • Node 3:

I’m going to assume you’ve followed the original tutorial and have Redis installed on all machines. Once you have that taken care of, you’re ready to move on to the clustering stage.

What you’ll need

You’ll need six machines with Redis running. The only other thing you’ll need is a user with sudo privileges. That’s it: Let’s cluster.

How to configure the cluster

You must edit the configuration file on all six machines. Open the file for editing with the command:

sudo nano /etc/redis/redis.conf

The first line you’ll need to change is the bind option. Where you might see either bind or bind, you’ll want to replace that with:


Where SERVER is the IP address of that particular machine. So Controller 1 will (in my example) be:


Controller 2 would be:


Et cetera.

The next lines to be configured will look like this:

protected-mode no
port 7000
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 15000
appendonly yes

Save and close the file.

Restart Redis on each machine with:

sudo systemctl restart redis

How to initialize the cluster

With everything configured, it’s time to initialize the cluster. This is handled with the Redis CLI common and must be run with each IP:port like so:

redis-cli --cluster create --cluster-replicas 1

The --cluster-replicas 1 option means there’ll be exactly one node for each controller. The output of the command will display each node along with a randomly generated ID for each. Make sure to type yes when prompted and the cluster will be initialized.

If you want to check on the status of each node, you can do so with the command:

redis-cli -h -p 7000 cluster nodes

The output of the above command should list all nodes.

Congratulations, you just deployed your first Redis cluster for high availability and failover. This might be the easiest cluster setup you’ll ever experience and the benefit you gain from having auto failover cannot be overstated.

Enjoy that added Redis power.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.