0
0
Redisquery~5 mins

Sentinel configuration in Redis

Choose your learning style9 modes available
Introduction

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

You want your Redis database to keep working even if the main server stops.
You need automatic switching to a backup Redis server without manual work.
You want to monitor Redis servers and get alerts if something goes wrong.
You want to manage multiple Redis servers easily in a group.
You want to avoid downtime in your app that uses Redis.
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 Sentinels must agree before switching to a backup.

Examples
This tells Sentinel to watch a Redis server called 'mymaster' at IP 127.0.0.1 on port 6379, and it needs 2 Sentinels to agree to switch if the master fails.
Redis
sentinel monitor mymaster 127.0.0.1 6379 2
This sets Sentinel to consider the master down if it doesn't respond for 5000 milliseconds (5 seconds).
Redis
sentinel down-after-milliseconds mymaster 5000
This sets the maximum time Sentinel will try to switch to a backup to 60000 milliseconds (1 minute).
Redis
sentinel failover-timeout mymaster 60000
This allows only 1 replica to sync with the new master at the same time during failover.
Redis
sentinel parallel-syncs mymaster 1
Sample Program

This configuration sets up Sentinel to watch a Redis master at 192.168.1.100:6379, requires 2 Sentinels to agree before failover, waits 10 seconds before marking the master 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

Make sure all Sentinel instances have the same configuration for the master name and quorum.

Sentinel configuration is usually placed in a sentinel.conf file and loaded when Sentinel starts.

Changing Sentinel settings requires restarting Sentinel or sending a CONFIG REWRITE command.

Summary

Sentinel configuration tells Redis how to watch and protect your main server.

Key settings include the master name, IP, port, quorum, and timing values.

Proper Sentinel setup helps keep your Redis service reliable and automatic.