Question: How can you set up a Redis cluster with 2 nodes?


Setting up a Redis cluster with two nodes involves the following steps:

  1. Install Redis: You need to install Redis on each node. Use your OS package manager, or download and compile Redis from source.
wget tar xvzf redis-stable.tar.gz cd redis-stable make
  1. Configure each Redis instance for clustering: Modify the redis.conf file for each instance. Set the cluster-enabled option to yes, specify a cluster-config-file, and provide a cluster-node-timeout.
# redis.conf cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 appendonly yes
  1. Start the Redis instances: Start each Redis instance using their specific redis.conf files.
src/redis-server /path/to/redis.conf
  1. Create the Cluster: Use the redis-cli utility to create the cluster. Consider the IP addresses are and and they are both running Redis on port 7000.
redis-cli --cluster create
  1. Follow the prompts: The redis-cli utility will propose a configuration. Accept it.

Please note that Redis cluster requires at least three master nodes for robust failover and distributed storage. A cluster with only two nodes does not guarantee high availability. It's better to use a setup with at least three nodes if you want high availability and partition tolerance.

Was this content helpful?

Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.