Mastering Redis Sentinel: Setup, Failover, and Multi‑Sentinel Configuration
This article explains what Redis Sentinel is, its architecture, how to configure it in a master‑slave environment, and demonstrates handling of slave and master failures as well as setting up multiple Sentinel instances for high availability.
1. What Is Redis Sentinel
Redis Sentinel is an independent process that monitors the health of Redis master and slave instances. It can detect failures of the master or slaves and automatically promote a slave to become the new master.
2. Architecture
Single‑sentinel architecture:
Multiple‑sentinel architecture (sentinels monitor each other):
3. Environment
The example runs in a one‑master‑multiple‑slave setup.
4. Configuring Sentinel
Create a configuration file: vim sentinel.conf Add a monitor line: sentinel monitor taotaoMaster 127.0.0.1 6379 1 Explanation of the fields:
taotaoMaster – name of the master to monitor.
127.0.0.1 – master IP address.
6379 – master port.
1 – quorum (minimum number of sentinels that must agree).
Start the sentinel process: redis-sentinel ./sentinel.conf Console output shows the sentinel ID, the added monitor, discovered slaves, etc.
5. Slave Failure and Recovery
After killing a slave (PID 2826), Sentinel logs:
2989:X 05 Jun 20:09:33.509 # +sdown slave 127.0.0.1:6380 127.0.0.1 6380 @ taotaoMaster 127.0.0.1 6379When the slave is restarted, Sentinel logs +reboot and then -sdown, indicating the slave has rejoined.
6. Master Failure and Failover
When the master goes down, Sentinel logs a series of events:
+sdown master ... +odown master ... +try-failover ... +vote-for-leader ... +elected-leader ... +failover-state-select-slave ... +failover-state-send-slaveof-noone ... +promoted-slave ... +slave-reconf-sent ... +slave-reconf-done ... +switch-master ...These messages show the election of a new master, reconfiguration of slaves, and completion of failover.
7. Configuring Multiple Sentinels
To run several sentinels, add multiple monitor lines:
sentinel monitor taotaoMaster1 127.0.0.1 6381 1 sentinel monitor taotaoMaster2 127.0.0.1 6381 2Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
