Redis Sentinel is the open-source HA layer for non-clustered Redis — it monitors a primary and one or more replicas, detects primary failure, promotes a replica, and tells clients about the new primary. It is the right tool for single-shard workloads that need automatic failover; for multi-shard workloads, Redis Cluster is the alternative. This article walks the three-node Sentinel quorum that you actually want in production, the configuration that ties Sentinel to the Redis pair it monitors, and the client-discovery pattern that makes failover transparent to applications.
How to verify
# Sentinel processes running
sudo systemctl status redis-sentinel --no-pager
# Sentinel sees the master
redis-cli -p 26379 SENTINEL master mymaster
# Sentinel sees the replicas
redis-cli -p 26379 SENTINEL replicas mymaster
redis-cli -p 26379 SENTINEL sentinels mymaster
# Where Sentinel thinks the master is right now
redis-cli -p 26379 SENTINEL get-master-addr-by-name mymaster
SENTINEL master mymaster returns dozens of fields; the important ones are flags (should include master, not s_down or o_down), num-slaves, num-other-sentinels, and quorum.
What’s happening
A Sentinel topology has three components:
- A Redis primary (writes accepted).
- One or more Redis replicas that replicate from the primary.
- Three or more Sentinel processes that observe the Redis pair and gossip among themselves.
Each Sentinel pings the primary periodically. If down-after-milliseconds (default 30 seconds) passes without a reply, the Sentinel marks the primary subjectively-down (s_down). When enough Sentinels (the quorum) agree, the primary is marked objectively-down (o_down). At that point the Sentinels elect a leader from among themselves, which then picks one of the replicas to promote.
After promotion, the new primary starts accepting writes; the old primary (if it comes back) is reconfigured as a replica; the Sentinels update their internal state; and on the next SENTINEL get-master-addr-by-name call, clients see the new primary’s address.
Three Sentinels is the minimum production count. With two, a network partition can leave both Sentinels unable to reach quorum (each is alone). With three, even after one Sentinel or one network domain fails, the remaining two can still agree.
The procedure
Assume the topology:
redis01(10.0.0.5) — primaryredis02(10.0.0.6) — replicaredis03(10.0.0.7) — replica AND a Sentinelredis01,redis02also run Sentinels
-
Start with a working Redis primary-replica pair. On
redis02andredis03, configure as replicas in/etc/redis/redis.conf:replicaof 10.0.0.5 6379 masterauth strong-password requirepass strong-passwordRestart and verify with
redis-cli -a strong-password INFO replication—role:slaveon the replicas,role:masteron the primary. -
Install Sentinel (ships with Redis on Ubuntu).
sudo apt install -y redis-sentinel -
Configure
/etc/redis/sentinel.confidentically on all three Sentinel hosts.port 26379 bind 127.0.0.1 10.0.0.5 # this host's private IP sentinel monitor mymaster 10.0.0.5 6379 2 sentinel auth-pass mymaster strong-password sentinel down-after-milliseconds mymaster 10000 sentinel parallel-syncs mymaster 1 sentinel failover-timeout mymaster 60000 sentinel deny-scripts-reconfig yes logfile /var/log/redis/sentinel.log dir /var/lib/redis-sentinelThe
2at the end ofsentinel monitoris the quorum — the number of Sentinels that must agree the primary is down before failover. -
Set ACLs or
requirepassconsistently. Sentinels need to authenticate to Redis withauth-pass. Modern Sentinel (6.2+) also requires its own password for inter-Sentinel auth:requirepass <sentinel-password> sentinel sentinel-pass mymaster <sentinel-password> -
Start Sentinels on all three hosts.
sudo systemctl enable --now redis-sentinel sudo systemctl status redis-sentinel --no-pager sudo tail -20 /var/log/redis/sentinel.log -
Verify the topology is recognized.
redis-cli -p 26379 SENTINEL master mymaster redis-cli -p 26379 SENTINEL replicas mymaster redis-cli -p 26379 SENTINEL sentinels mymasternum-other-sentinelsshould be 2 (the other two Sentinels seen by this one). -
Test failover. Kill the primary’s Redis (not Sentinel).
sudo systemctl stop redis-server # on redis01On any Sentinel, watch the failover happen (about 10-15 seconds):
sudo tail -f /var/log/redis/sentinel.logThen query the new master:
redis-cli -p 26379 SENTINEL get-master-addr-by-name mymaster # Returns the new primary's IP:portBring the old primary back; it rejoins as a replica.
-
Configure clients for Sentinel-aware discovery. Most modern clients support this — examples:
- Python (redis-py):
Sentinel([('redis01', 26379), ('redis02', 26379), ('redis03', 26379)], password='...').master_for('mymaster') - Node (ioredis):
new Redis({ sentinels: [{host:'redis01',port:26379}, ...], name: 'mymaster' }) - Java (Jedis):
JedisSentinelPool('mymaster', sentinels, ...) - Go (go-redis):
redis.NewFailoverClient(&redis.FailoverOptions{MasterName: 'mymaster', SentinelAddrs: ...})
The client connects to the Sentinels first, gets the current master, and reconnects there. On failover, the client transparently switches.
- Python (redis-py):
-
Operator best practice — never
CONFIG SETdirectly on the master. Sentinel manages replica reconfiguration; manualreplicaofcommands orCONFIG SETcan confuse it. Apply changes viaSENTINEL setor by editingsentinel.confand restarting Sentinel.
Common pitfalls
- Quorum = 2 with only 2 Sentinels never reaches quorum if either goes down. Always run an odd number of Sentinels, with quorum set to a majority (3 Sentinels → quorum 2; 5 Sentinels → quorum 3).
- Sentinel and the Redis it monitors on the same host means one host failure takes out both. Run Sentinels on the same hosts as Redis if you have only three hosts, but ensure those three hosts are in different failure domains.
- Clients that cache the master address bypass Sentinel after the initial discovery — make sure your client uses Sentinel-aware reconnect (or has a short connection lifetime).
- After a failover, the old master rejoins as a replica with its old credentials — if you rotated
masterauthbetween failover and recovery, the old master cannot replicate until you fix the password. - Sentinel does not split partition data — if you need sharding, use Redis Cluster (a different topology). Sentinel + replication is single-shard HA only.
In the engagements we run, single-shard Redis with Sentinel is our default HA pattern for caching and session-store workloads up to a couple hundred GB. For sharded workloads we use Redis Cluster or a managed service. We monitor Sentinel quorum, primary uptime, and replication lag, with alerts on failover events and on quorum loss. Operated under Managed Operations — and the broader HA design lives under Clustered Environments.