Redis Deployment Configurations: Standalone, Master-Slave, Sentinel, and Cluster

Standalone Configuraton Setup

Redis Installation

Download URL: http://redis.io/download

Installation Steps:

  1. Install gcc compiler: yum install gcc
  2. Download and extract the redis-5.0.3.tar.gz file to /usr/local directory
wget http://download.redis.io/releases/redis-5.0.3.tar.gz
tar xzf redis-5.0.3.tar.gz
cd redis-5.0.3
  1. Navigate to the extracted redis-5.0.3 directory and compile
make
  1. Modify configuration
daemonize yes
protected-mode no
# Comment out the bind directive
# bind 127.0.0.1
  1. Start the service
src/redis-server redis.conf
  1. Verify service startup
ps -ef | grep redis
  1. Access the redis client
src/redis-cli
  1. Exit the cleint
quit
  1. Methods to stop redis service:
  • pkill redis-server
  • kill [process_id]
  • src/redis-cli shutdown

Master-Slave Architecture

Steps to configure a Redis master-slave setup:

  1. Copy the redis.conf file for the slave node
cp redis.conf redis_slave.conf
  1. Modify the slave configuration file
port 6380
pidfile /var/run/redis_slave_6380.pid
logfile "slave_6380.log"
dir /usr/local/redis-5.0.3/data/6380
# Comment out bind directive
# bind 127.0.0.1
  1. Configure replication in the slave
replicaof 192.168.0.60 6379
replica-read-only yes
  1. Start the slave node
redis-server redis_slave.conf
  1. Connect to the slave node
redis-cli -p 6380
  1. Test data synchronization by writing to the master (6379) and checking if it appears on the slave (6380)

  2. Additional slave nodes can be configured similarly (e.g., port 6381)

Sentinel High-Availability Architecture

Steps to build a Redis Sentinel setup:

  1. Copy a sentinel configuration file
cp sentinel.conf sentinel_sentinel.conf
  1. Modify the sentinel configuration file
daemonize yes
pidfile "/var/run/redis-sentinel_sentinel.pid"
logfile "sentinel_sentinel.log"
dir "/usr/local/redis-5.0.3/data"
# sentinel monitor <master-name> <master-ip> <master-port> <quorum>
sentinel monitor mymaster 192.168.0.60 6379 2</quorum></master-port></master-ip></master-name>
  1. Start the sentinel enstance
src/redis-sentinel sentinel_sentinel.conf
  1. Check sentinel information
127.0.0.1:26379> info
  1. Configure additional sentinel instances (ports 26380, 26381) with appropriate configuration changes

High-Availability Cluster Mode

To set up a Redis cluster, a minimum of three master nodes is required. This example uses three master nodes with one replica each, totaling six Redis instances deployed across three machines (one master and one replica per machine).

  1. Create a redis-cluster directory and subdirectories for each node
mkdir -p /usr/local/redis-cluster
mkdir 8001 8004
  1. Copy and modify the redis.conf file for port 8001
daemonize yes
port 8001
pidfile /var/run/redis_cluster_8001.pid
dir /usr/local/redis-cluster/8001/
cluster-enabled yes
cluster-config-file nodes_cluster_8001.conf
cluster-node-timeout 10000
protected-mode no
appendonly yes
# Password configuration (optional)
requirepass clusterpass
masterauth clusterpass
  1. Copy the modified configuration to the 8004 directory and update port references
# In vim editor, use:
:%s/8001/8004/g
  1. Repeat steps 2-3 for the other two machines:

    • Machine 2: ports 8002 and 8005
    • Machine 3: ports 8003 and 8006
  2. Start all six Redis instances and verify

/usr/local/redis-5.0.3/src/redis-server /usr/local/redis-cluster/800*/redis.conf
ps -ef | grep redis
  1. Create the Redis cluster using redis-cli (Redis 5+)
/usr/local/redis-5.0.3/src/redis-cli -a clusterpass --cluster create --cluster-replicas 1 192.168.0.61:8001 192.168.0.62:8002 192.168.0.63:8003 192.168.0.61:8004 192.168.0.62:8005 192.168.0.63:8006
  1. Verify the cluster
# Connect to any node
/usr/local/redis-5.0.3/src/redis-cli -a clusterpass -c -h 192.168.0.61 -p 8001

# Check cluster status
cluster info
cluster nodes

# Test data operations

# To shutdown the cluster, stop each node individually
/usr/local/redis-5.0.3/src/redis-cli -a clusterpass -c -h 192.168.0.61 -p 8001 shutdown

Tags: Redis Standalone Deployment Master-Slave Architecture Sentinel Redis Cluster

Posted on Wed, 22 Jul 2026 16:53:04 +0000 by thechris