Redis Sentinel Mode Configuration and High Availability Setup

Installing Redis and Enabling Auto-start

Install Redis and configure it to start automatically at system boot.

Deploying Multiple Redis Instances

Set up multiple Redis servers for redundancy and high availability.

Configuring Redis Password Authentication

Secure Redis instances using password-based authentication.

Setting Up Redis Persistence

Configure Redis persistence mechanisms to ensure data durability.

Establishing Master-Slave Replication

Set up Redis master-slave replication for data redundancy.

Redis Sentinel Configuration

Configure Redis Sentinel to monitor and manage failover processes.

Sentinel Configuration File Setup

Create a dedicated directory for Sentinel configuration files:

mkdir -p /etc/redis/sentinel

Copy the default Sentinel configuration file:

cp /opt/redis-stable/sentinel.conf /etc/redis/sentinel/6379.conf

Edit the Sentinel configuration (/etc/redis/sentinel/6379.conf) with the following settings:

daemonize yes
pidfile /var/run/redis-sentinel-6379.pid
logfile /var/log/redis-sentinel-6379.log

# Monitor the master instance
sentinel monitor mymaster 127.0.0.1 6379 2

# Timeout for marking a node as unreachable
sentinel down-after-milliseconds mymaster 30000

# Authentication password for the master
sentinel auth-pass mymaster 123456

# Failover timeout setting
sentinel failover-timeout mymaster 180000

Duplicate the configuration for a second Sentinel instance:

cp /etc/redis/sentinel/6379.conf /etc/redis/sentinel/6380.conf

Modify the second configuration (/etc/redis/sentinel/6380.conf):

port 26380
pidfile /var/run/redis-sentinel-6380.pid
logfile /var/log/redis-sentinel-6380.log

Starting Sentinel Instances

Launch both Sentinel processes:

/usr/local/src/redis/bin/redis-server /etc/redis/sentinel/6379.conf --sentinel
/usr/local/src/redis/bin/redis-server /etc/redis/sentinel/6380.conf --sentinel

Monitoring Sentinel Logs

Monitor the log output for Sentinel activities:

tail -fn 300 /var/log/redis-sentinel-6379.log
tail -fn 300 /var/log/redis-sentinel-6380.log

Testing Failover Behavior

Stop the primary Redis instance:

/etc/init.d/redis_6379 stop

Connect to the slave instance via CLI:

/usr/local/src/redis/bin/redis-cli -a 123456 -c -h 127.0.0.1 -p 6380

Check replication status:

info replication

Observe that the role has changed from slave to master, and the number of connected slaves is zero.

Restart the primary Redis instance to restore its role as a slave:

/etc/init.d/redis_6379 start

Note that the number of connected slaves remains zero due to missing masterauth configuration during initial setup. It's recommended to set masterauth when configuring master-slave relationships to ensure proper failover behavior in production environments:

masterauth 123456

Tags: Redis Sentinel high-availability failover Replication

Posted on Sun, 30 Aug 2026 16:43:10 +0000 by ryansmith44