0
0
Redisquery~5 mins

Sentinel architecture in Redis

Choose your learning style9 modes available
Introduction

Sentinel architecture helps keep your Redis database safe and working well by watching over it and fixing problems automatically.

You want your Redis database to keep working even if one server stops.
You need automatic switching to a backup Redis server when the main one fails.
You want to be alerted if your Redis servers have problems.
You want to manage multiple Redis servers easily without manual checks.
Syntax
Redis
sentinel monitor <master-name> <ip> <port> <quorum>
sentinel down-after-milliseconds <master-name> <milliseconds>
sentinel failover-timeout <master-name> <milliseconds>
sentinel parallel-syncs <master-name> <number>

master-name is a name you give to your main Redis server.

quorum is how many Sentinel instances must agree a server is down before action.

Examples
This tells Sentinel to watch a Redis server called 'mymaster' at IP 127.0.0.1 and port 6379. It needs 2 Sentinels to agree before marking it down.
Redis
sentinel monitor mymaster 127.0.0.1 6379 2
Sentinel will consider 'mymaster' down if it does not respond for 5000 milliseconds (5 seconds).
Redis
sentinel down-after-milliseconds mymaster 5000
Sentinel will try to switch to a backup server within 60000 milliseconds (1 minute) if 'mymaster' fails.
Redis
sentinel failover-timeout mymaster 60000
Sample Program

This configuration sets up Sentinel to watch a Redis master server at IP 192.168.1.100 on port 6379. It requires 2 Sentinels to agree before marking the master down. It waits 10 seconds before deciding the master is down, allows 3 minutes for failover, and syncs one replica at a time.

Redis
sentinel monitor mymaster 192.168.1.100 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 180000
sentinel parallel-syncs mymaster 1
OutputSuccess
Important Notes

Sentinel runs as a separate process alongside Redis servers.

Multiple Sentinel instances improve reliability by agreeing on server status.

Failover means switching to a backup Redis server automatically to keep your app running.

Summary

Sentinel architecture watches Redis servers to detect failures.

It automatically switches to backups to keep data available.

It helps manage Redis servers easily and reliably.