0
0
Redisquery~5 mins

Why Sentinel provides high availability in Redis

Choose your learning style9 modes available
Introduction

Sentinel helps keep your Redis database working even if some parts fail. It watches over Redis servers and quickly fixes problems to avoid downtime.

You want your Redis database to keep running even if one server crashes.
You need automatic switching to a backup Redis server without manual work.
You want to be alerted if your Redis servers have problems.
You want to manage multiple Redis servers easily with automatic failover.
Syntax
Redis
Sentinel runs as a separate process and monitors Redis servers.
It uses configuration files to know which servers to watch.
When a master server fails, Sentinel promotes a replica to master automatically.
Sentinel is not a command but a system that runs alongside Redis servers.
It uses a voting system among multiple Sentinel instances to decide on failover.
Examples
This config tells Sentinel to watch a master Redis server at 127.0.0.1:6379 and start failover if it is down for 5 seconds.
Redis
# sentinel.conf example
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 60000
sentinel parallel-syncs mymaster 1
This command starts the Sentinel process using the configuration file.
Redis
# Starting Sentinel
redis-sentinel /path/to/sentinel.conf
Sample Program

This example shows how Sentinel works in practice by monitoring and promoting Redis servers automatically.

Redis
# This is a conceptual example, not a query.
# Sentinel monitors Redis master and replicas.
# If master fails, Sentinel promotes a replica automatically.
# Sentinel also notifies clients about the new master.

# To test, stop the master Redis server and watch Sentinel logs.
OutputSuccess
Important Notes

Sentinel requires at least three Sentinel instances for reliable failover decisions.

Sentinel helps avoid downtime by automatically switching to a healthy Redis server.

Summary

Sentinel watches Redis servers to detect failures quickly.

It automatically promotes a replica to master if the current master fails.

This process keeps your Redis service available without manual intervention.