QUICK START:PatternsErrors & FixesSecurityBenchmarksDevOps RecipesCheatsheetsInterviewCompareTopicsHTMLCSSJavaScriptTypeScriptPythonSQLReactNext.jsNode.jsLinux & UbuntuKotlinSwiftC# / .NETJavaGoRustC++DSASystem DesignDevOpsCybersecurityAI / ML
AdvancedDatabase & Storage

High-Availability Redis: Sentinel Auto-Failover

Ensure zero downtime for cache and session layers. This recipe walks through setting up Redis replication combined with Sentinel to monitor and promote replicas automatically.

RedisRedis Sentinel

Prerequisites

  • 3 Linux VMs (1 Master, 2 Replicas/Sentinels)

Configuration Files

sentinel.conf/etc/redis/sentinel.conf
port 26379\nsentinel monitor mymaster 192.168.1.10 6379 2\nsentinel down-after-milliseconds mymaster 5000\nsentinel failover-timeout mymaster 10000\nsentinel auth-pass mymaster securepassword
Explanation:Configures Sentinel to monitor the master at 192.168.1.10. A quorum of 2 Sentinels must agree the master is down before failover.

Verification Steps

1

Checks the cluster state from Sentinel's perspective.

$redis-cli -p 26379 info sentinel
Expected Outputstatus=ok,address=192.168.1.10:6379,slaves=2,sentinels=3

Production Gotchas

  • Clients connecting to Redis must support the Sentinel protocol to ask for the current master address upon failover.

Frequently Asked Questions

What is a split-brain scenario?

When a network partition causes multiple nodes to believe they are the master, corrupting data. Quorum (majority vote) prevents this.