Sentinel Guide

sentinel.conf Configuration

Minimum 3 Sentinel instances are recommended for quorum-based failover.

# sentinel.conf
port 26379
daemonize yes
logfile /var/log/redis/sentinel.log
dir /tmp

# monitor: name host port quorum
sentinel monitor mymaster 127.0.0.1 6379 2

# Timeout before considering master down (milliseconds)
sentinel down-after-milliseconds mymaster 5000

# How many replicas can be simultaneously reconfigured during failover
sentinel parallel-syncs mymaster 1

# Failover timeout (ms): how long before re-trying failed failover
sentinel failover-timeout mymaster 60000

# Authentication (if master requires a password)
sentinel auth-pass mymaster s3cret

# TLS (Redis 6+)
# sentinel tls-port 26380
# sentinel tls-cert-file /path/to/cert.pem

# Start Sentinel
# redis-sentinel /etc/redis/sentinel.conf
# or: redis-server /etc/redis/sentinel.conf --sentinel

Sentinel API Commands

# Connect to Sentinel (port 26379 by default)
redis-cli -p 26379

# Check master info
SENTINEL master mymaster

# List all monitored masters
SENTINEL masters

# List replicas of a master
SENTINEL replicas mymaster

# List other Sentinel instances
SENTINEL sentinels mymaster

# Get current master address (useful for clients)
SENTINEL get-master-addr-by-name mymaster
# Returns: 1) "127.0.0.1"  2) "6379"

# Check Sentinel health
SENTINEL ping

# Reset state of monitored master
SENTINEL reset mymaster

# Trigger a manual failover
SENTINEL failover mymaster

# Flush config to disk
SENTINEL flushconfig

Connecting via Sentinel (Node.js)

// ioredis Sentinel connection
const Redis = require("ioredis");
const client = new Redis({
  sentinels: [
    { host: "sentinel1", port: 26379 },
    { host: "sentinel2", port: 26379 },
    { host: "sentinel3", port: 26379 }
  ],
  name: "mymaster",
  password: "s3cret",        // master password
  sentinelPassword: "sentpass", // sentinel auth (Redis 6+)
  role: "master"             // "master" or "slave"
});

// ioredis auto-discovers new master on failover
client.on("error", err => console.error("Redis error:", err));
client.on("+switch-master", (master, oldHost, oldPort, newHost, newPort) => {
  console.log(`Failover: ${newHost}:${newPort}`);
});

Failover Process

StepDescription
1. Subjective Down (SDOWN)A Sentinel fails to reach master within down-after-milliseconds
2. Objective Down (ODOWN)Quorum number of Sentinels agree master is down
3. Leader ElectionSentinels elect a leader to manage the failover
4. Replica PromotionBest replica is selected and promoted to master
5. ReconfigurationOther replicas and clients are reconfigured to use new master

Monitoring & Events

# Subscribe to Sentinel events
redis-cli -p 26379 PSUBSCRIBE '*'

# Common event channels:
# +sdown         - instance entered subjective down
# -sdown         - instance left subjective down
# +odown         - instance entered objective down
# -odown         - instance left objective down
# +slave         - new replica discovered
# +sentinel      - new sentinel discovered
# +failover-state-reconf-slaves - failover started
# +failover-end  - failover completed
# +switch-master - master address changed

# Monitor Sentinel logs
tail -f /var/log/redis/sentinel.log