A single Redis instance has two failure modes: if the server goes down, all cached data is lost and every request hits the origin database; and if the dataset grows beyond a single server’s RAM, there’s no built-in way to distribute it. Redis provides two solutions: Redis Sentinel for high availability (automatic failover with a primary and one or more replicas), and Redis Cluster for horizontal sharding across multiple nodes (distributes data across 16,384 hash slots, each node holds a subset). Redis Cluster also provides HA — each shard can have its own replica. For most production workloads, Sentinel is simpler to operate (no application changes needed with most Redis clients), while Cluster is appropriate when the dataset exceeds a single server’s RAM. This guide covers setting up a 3-node Redis Sentinel deployment on RHEL 9.
Prerequisites
- Three RHEL 9 servers with Redis installed
- Primary:
10.0.1.10| Replica 1:10.0.1.11| Replica 2:10.0.1.12
Step 1 — Configure Redis Primary
# /etc/redis/redis.conf on PRIMARY (10.0.1.10)
bind 10.0.1.10 127.0.0.1
port 6379
requirepass StrongRedisPassword!
masterauth StrongRedisPassword! # Needed when replicas/sentinels authenticate
appendonly yes
systemctl restart redis
Step 2 — Configure Redis Replicas
# /etc/redis/redis.conf on EACH REPLICA (10.0.1.11 and 10.0.1.12)
bind 0.0.0.0
port 6379
requirepass StrongRedisPassword!
masterauth StrongRedisPassword!
replicaof 10.0.1.10 6379 # Point to primary
replica-read-only yes
systemctl restart redis # On both replicas
Step 3 — Configure Redis Sentinel on All Three Nodes
# /etc/redis/sentinel.conf on ALL THREE nodes (change bind address per node)
bind 10.0.1.10 # Change to each node's IP
port 26379
# Monitor the primary — quorum=2 (2 of 3 sentinels must agree for failover)
sentinel monitor mymaster 10.0.1.10 6379 2
sentinel auth-pass mymaster StrongRedisPassword!
sentinel down-after-milliseconds mymaster 5000 # Mark primary down after 5s
sentinel failover-timeout mymaster 60000 # Failover timeout 60s
sentinel parallel-syncs mymaster 1 # Sync one replica at a time during failover
# Start Sentinel on all three nodes
systemctl enable --now redis-sentinel
Step 4 — Open Firewall Ports
firewall-cmd --permanent --add-port=6379/tcp # Redis
firewall-cmd --permanent --add-port=26379/tcp # Sentinel
firewall-cmd --reload
Step 5 — Verify Sentinel Topology
# Check Sentinel sees the primary and all replicas
redis-cli -h 10.0.1.10 -p 26379 sentinel master mymaster
redis-cli -h 10.0.1.10 -p 26379 sentinel replicas mymaster
redis-cli -h 10.0.1.10 -p 26379 sentinel sentinels mymaster
# Check replication on primary
redis-cli -h 10.0.1.10 -a StrongRedisPassword! info replication
Step 6 — Application Connection with Sentinel
# Python with redis-py (Sentinel-aware client)
python3 <<'PYEOF'
from redis.sentinel import Sentinel
sentinel = Sentinel([
('10.0.1.10', 26379),
('10.0.1.11', 26379),
('10.0.1.12', 26379)
], password='StrongRedisPassword!', sentinel_kwargs={'password': 'StrongRedisPassword!'})
master = sentinel.master_for('mymaster', decode_responses=True)
master.set('test', 'hello')
print(master.get('test'))
PYEOF
Conclusion
Redis Sentinel on RHEL 9 provides automatic primary election and failover for Redis with a 3-node quorum. When the primary fails, Sentinel detects the failure within seconds and promotes the replica with the most up-to-date data to become the new primary — without manual intervention. Sentinel-aware Redis clients automatically reconnect to the new primary after failover, ensuring minimal disruption to the application.
Next steps: How to Install Redis on RHEL 9, How to Install Memcached on RHEL 9, and How to Configure HAProxy for Load Balancing on RHEL 9.