How to Setup Local Redis Cluster

Vedant Kekan
2 min readAug 5, 2024

--

In this document we will learn how to setup a Redis cluster step by step. And go through all the important topics listed below which we need to understand for mastering Redis Cluster setup.

In this example we will create a 6 nodes cluster (3 master and 3 replicas).

First make sure you have redis installed on your system

Create Redis Cluster

  • We need to have few empty Redis instances running in cluster mode.
  • We need at least following directives in our redis.config
port 8000
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes

On local we will create 6 different folders where we will maintain config of each node and start Redis on same host different ports.

mkdir cluster-test
cd cluster-test
mkdir 8000 8001 8002 8003 8004 8005

Create a redis.conf file inside each of the directories, from 7000 to 7005
make sure to replace the port number 7000 with the right port number according to the directory name.

Start every instance in different terminal with following commands

cd 8000
redis-server ./redis.conf

cd 8001
redis-server ./redis.conf

cd 8002
redis-server ./redis.conf

cd 8003
redis-server ./redis.conf

cd 8004
redis-server ./redis.conf

cd 8005
redis-server ./redis.conf

Now we will create cluster with create command

redis-cli --cluster create 127.0.0.1:8000 127.0.0.1:8001 \
127.0.0.1:8002 127.0.0.1:8003 127.0.0.1:8004 127.0.0.1:8005 \
--cluster-replicas 1

--cluster-replicas 1 means that we want a replica for every master created.

Here is a video ghuide for same:

--

--

Vedant Kekan
Vedant Kekan

Written by Vedant Kekan

Exploring this beautiful world.

No responses yet