Databases 8 min read

Mastering Redis Sentinel: Setup, Failover, and High‑Availability Guide

This article explains what Redis Sentinel is, its architecture, how to configure sentinel.conf, monitor master and slaves, handle slave and master failures, and set up multiple sentinel instances for robust high‑availability in a Redis master‑slave environment.

Programmer DD
Programmer DD
Programmer DD
Mastering Redis Sentinel: Setup, Failover, and High‑Availability Guide

1. What Is Redis Sentinel

Redis Sentinel monitors the health of a Redis deployment. It runs as an independent process and provides two main functions: monitoring whether the master and slave databases are operating correctly, and automatically promoting a slave to master when the current master fails.

2. Architecture

Single Sentinel architecture:

Multiple Sentinel architecture (Sentinels monitor each other as well):

3. Environment

The example assumes a master‑with‑multiple‑slaves setup:

4. Configuring Sentinel

Create a sentinel configuration file: vim sentinel.conf Add a monitor line (replace values as needed): sentinel monitor taotaoMaster 127.0.0.1 6379 1 Explanation of the fields: . - _ characters are allowed in the master name.

127.0.0.1 – IP of the master.

6379 – port of the master.

1 – minimum number of votes required.

Start the sentinel process: redis-sentinel ./sentinel.conf Sample console output shows the sentinel ID, the monitored master, discovered slaves, etc.

5. Slave Failure and Recovery

After killing a slave process, 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 6379

When the slave is restarted, Sentinel logs a reboot and then clears the down state, indicating the slave has rejoined replication.

6. Master Failure and Recovery

When the master goes down, Sentinel logs a series of events that illustrate the failover process:

2989:X 05 Jun 20:16:50.300 # +sdown master taotaoMaster 127.0.0.1 6379  # master down
2989:X 05 Jun 20:16:50.300 # +odown master taotaoMaster 127.0.0.1 6379 # quorum reached
2989:X 05 Jun 20:16:50.300 # +new-epoch 1
2989:X 05 Jun 20:16:50.300 # +try-failover master taotaoMaster 127.0.0.1 6379
... (election, promotion of a slave to master, reconfiguration of remaining slaves) ...
2989:X 05 Jun 20:16:52.438 # +switch-master taotaoMaster 127.0.0.1 6379 127.0.0.1 6381

The logs demonstrate Sentinel electing a leader, selecting a slave to promote, sending the appropriate commands, and finally updating the topology so that the former slave becomes the new master.

7. Configuring Multiple Sentinels

Edit sentinel.conf to add several monitor lines, for example:

sentinel monitor taotaoMaster1 127.0.0.1 6381 1

sentinel monitor taotaoMaster2 127.0.0.1 6381 2

This allows multiple Sentinel instances to cooperate, providing redundancy against single‑point failures.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

databasehigh availabilityredisConfigurationsentinelfailover
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.