Configure Redis Sentinel for high availability and automatic failover

Intermediate 25 min Apr 01, 2026 11 views
Ubuntu 24.04 Debian 12 AlmaLinux 9 Rocky Linux 9

Set up Redis Sentinel to monitor Redis master-replica deployments and automatically handle failover scenarios. This tutorial covers configuring a 3-node Sentinel cluster with quorum-based decision making for production-grade high availability.

Prerequisites

  • At least 3 servers for proper quorum
  • Network connectivity between all nodes
  • Basic understanding of Redis replication

What this solves

Redis Sentinel provides high availability for Redis deployments by monitoring master and replica instances, detecting failures, and automatically promoting replicas to master when needed. This eliminates single points of failure and ensures your Redis service remains available during hardware or network issues.

Step-by-step configuration

Update system packages

Start by updating your package manager to ensure you get the latest Redis packages.

sudo apt update && sudo apt upgrade -y
sudo dnf update -y

Install Redis server

Install Redis on all nodes that will participate in the Sentinel cluster. You'll need Redis installed even on Sentinel-only nodes.

sudo apt install -y redis-server redis-sentinel
sudo dnf install -y redis redis-sentinel epel-release

Configure Redis master instance

Configure the primary Redis instance that will initially serve as master. Set up authentication and bind to the appropriate network interface.

# Network and security
bind 0.0.0.0
protected-mode yes
port 6379
requirepass StrongMasterPass123
masterauth StrongMasterPass123

Persistence

save 900 1 save 300 10 save 60 10000 rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir /var/lib/redis

Logging

loglevel notice logfile /var/log/redis/redis-server.log syslog-enabled yes syslog-ident redis

Memory management

maxmemory-policy allkeys-lru tcp-keepalive 300

Configure Redis replica instances

Set up replica instances on separate servers. These will automatically sync with the master and can be promoted during failover.

# Network and security
bind 0.0.0.0
protected-mode yes
port 6379
requirepass StrongReplicaPass123
masterauth StrongMasterPass123

Replication configuration

replicaof 203.0.113.10 6379 replica-read-only yes replica-serve-stale-data yes replica-priority 100

Persistence

save 900 1 save 300 10 save 60 10000 rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir /var/lib/redis

Logging

loglevel notice logfile /var/log/redis/redis-server.log syslog-enabled yes syslog-ident redis

Memory management

maxmemory-policy allkeys-lru tcp-keepalive 300

Set correct Redis file permissions

Ensure Redis can read its configuration and write to data directories with proper ownership and minimal permissions.

sudo chown redis:redis /etc/redis/redis.conf
sudo chmod 640 /etc/redis/redis.conf
sudo chown -R redis:redis /var/lib/redis
sudo chmod 755 /var/lib/redis
sudo chown redis:redis /var/log/redis
sudo chmod 755 /var/log/redis
Never use chmod 777. It gives every user on the system full access to your Redis files. Instead, use proper ownership with chown and minimal permissions as shown above.

Configure Redis Sentinel on first node

Set up the first Sentinel instance with monitoring configuration and quorum settings. The quorum determines how many Sentinels must agree before initiating failover.

# Basic Sentinel configuration
port 26379
bind 0.0.0.0
protected-mode no
sentinel deny-scripts-reconfig yes

Monitor master instance

sentinel monitor mymaster 203.0.113.10 6379 2 sentinel auth-pass mymaster StrongMasterPass123 sentinel down-after-milliseconds mymaster 5000 sentinel parallel-syncs mymaster 1 sentinel failover-timeout mymaster 30000

Logging

logfile /var/log/redis/sentinel.log loglevel notice syslog-enabled yes syslog-ident sentinel

Working directory

dir /var/lib/redis/sentinel

Configure additional Sentinel nodes

Deploy identical Sentinel configurations on at least two more servers for redundancy. Use the same master IP but different Sentinel IDs.

# Basic Sentinel configuration
port 26379
bind 0.0.0.0
protected-mode no
sentinel deny-scripts-reconfig yes

Monitor master instance (same as other Sentinels)

sentinel monitor mymaster 203.0.113.10 6379 2 sentinel auth-pass mymaster StrongMasterPass123 sentinel down-after-milliseconds mymaster 5000 sentinel parallel-syncs mymaster 1 sentinel failover-timeout mymaster 30000

Logging

logfile /var/log/redis/sentinel.log loglevel notice syslog-enabled yes syslog-ident sentinel

Working directory

dir /var/lib/redis/sentinel

Create Sentinel working directory

Create the directory where Sentinel stores its runtime state and ensure proper permissions.

sudo mkdir -p /var/lib/redis/sentinel
sudo chown redis:redis /var/lib/redis/sentinel
sudo chmod 755 /var/lib/redis/sentinel
sudo chown redis:redis /etc/redis/sentinel.conf
sudo chmod 640 /etc/redis/sentinel.conf

Configure firewall rules

Open the necessary ports for Redis and Sentinel communication between cluster nodes.

sudo ufw allow from 203.0.113.0/24 to any port 6379 comment 'Redis'
sudo ufw allow from 203.0.113.0/24 to any port 26379 comment 'Redis Sentinel'
sudo ufw reload
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.0/24" port protocol="tcp" port="6379" accept'
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.0/24" port protocol="tcp" port="26379" accept'
sudo firewall-cmd --reload

Start Redis master and replica services

Enable and start Redis on the master and replica nodes first, then verify replication is working.

sudo systemctl enable --now redis-server
sudo systemctl status redis-server

Start Redis Sentinel services

Start Sentinel on all three nodes after Redis instances are running and replication is established.

sudo systemctl enable --now redis-sentinel
sudo systemctl status redis-sentinel

Test automatic failover

Simulate master failure by stopping the Redis master service and observe Sentinel promoting a replica.

# On master node, stop Redis to simulate failure
sudo systemctl stop redis-server

Monitor Sentinel logs during failover

sudo tail -f /var/log/redis/sentinel.log

Check which instance is now master

redis-cli -p 26379 sentinel masters

Verify your setup

Check that Sentinel is monitoring your Redis instances and can detect the current master.

# Check Sentinel status
redis-cli -p 26379 sentinel masters
redis-cli -p 26379 sentinel slaves mymaster
redis-cli -p 26379 sentinel sentinels mymaster

Verify Redis replication

redis-cli -h 203.0.113.10 -a StrongMasterPass123 info replication

Test failover capabilities

redis-cli -p 26379 sentinel failover mymaster

Common issues

SymptomCauseFix
Sentinel can't connect to masterFirewall blocking ports or wrong IPCheck firewall rules and master bind address
Authentication failuresMismatched passwords in configVerify requirepass and masterauth match
Failover doesn't triggerInsufficient Sentinels or wrong quorumCheck at least 3 Sentinels running with quorum=2
Permission denied errorsWrong file ownership or permissionssudo chown redis:redis /etc/redis/* && chmod 640
Split-brain scenariosNetwork partitions with even Sentinel countAlways use odd number of Sentinels (3, 5, 7)

Next steps

Automated install script

Run this to automate the entire setup

#redis #sentinel #high-availability #failover #clustering

Need help?

Don't want to manage this yourself?

We handle infrastructure for businesses that depend on uptime. From initial setup to ongoing operations.

Talk to an engineer