Sentinel helps keep your Redis database safe and working by watching over it and fixing problems automatically.
Sentinel configuration in 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.
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel down-after-milliseconds mymaster 5000sentinel failover-timeout mymaster 60000sentinel parallel-syncs mymaster 1This 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.
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
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.
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.
Practice
Solution
Step 1: Understand Sentinel's role
Redis Sentinel monitors Redis servers to detect failures.Step 2: Identify failover capability
Sentinel automatically switches to a backup server if the master fails.Final Answer:
To monitor Redis servers and perform automatic failover if the master fails -> Option CQuick Check:
Sentinel = automatic failover [OK]
- Confusing Sentinel with data storage
- Thinking Sentinel speeds up queries
- Assuming Sentinel provides UI
mymaster on IP 192.168.1.100 and port 6379?Solution
Step 1: Recall Sentinel monitor command format
The correct command starts withsentinel monitorfollowed by master name, IP, port, and quorum.Step 2: Match the correct syntax
sentinel monitor mymaster 192.168.1.100 6379 2 matches the correct order and keywords.Final Answer:
sentinel monitor mymaster 192.168.1.100 6379 2 -> Option AQuick Check:
sentinel monitor = correct syntax [OK]
- Swapping 'monitor' and 'sentinel'
- Using 'set' or 'watch' instead of 'monitor'
- Incorrect order of parameters
sentinel monitor mymaster 10.0.0.1 6379 2 sentinel down-after-milliseconds mymaster 5000 sentinel failover-timeout mymaster 60000
What does the
down-after-milliseconds setting specify?Solution
Step 1: Understand 'down-after-milliseconds'
This setting defines how long Sentinel waits to consider the master unreachable.Step 2: Differentiate from failover timeout
Failover timeout is different; it controls failover duration, not detection.Final Answer:
The time Sentinel waits before declaring the master as down -> Option AQuick Check:
down-after-milliseconds = detection wait time [OK]
- Confusing with failover timeout
- Thinking it affects client connections
- Assuming it controls Redis write delay
sentinel monitor mymaster 10.0.0.1 6379
What is wrong with this configuration?
Solution
Step 1: Check required parameters for sentinel monitor
The command requires master name, IP, port, and quorum number.Step 2: Identify missing quorum
The quorum number (minimum votes to failover) is missing in the line.Final Answer:
Missing the quorum number at the end -> Option DQuick Check:
Quorum number required in sentinel monitor [OK]
- Ignoring quorum number
- Changing port unnecessarily
- Assuming master name must be 'master'
Solution
Step 1: Understand 'down-after-milliseconds'
This controls how fast Sentinel marks master as down; 5000 ms means 5 seconds.Step 2: Understand 'failover-timeout'
This controls how long failover can take; 60000 ms means 60 seconds (1 minute).Step 3: Combine settings for quick detection and failover
Setting down-after-milliseconds to 5000 and failover-timeout to 60000 ensures detection in 5 seconds and failover within 1 minute.Final Answer:
Set down-after-milliseconds to 5000 and failover-timeout to 60000 -> Option BQuick Check:
Fast detection + 1 min failover = Setdown-after-millisecondsto 5000 andfailover-timeoutto 60000 [OK]
- Swapping values of down-after and failover-timeout
- Setting only one parameter
- Using too high down-after-milliseconds
Ready to prove it?
Pass the test and this pattern moves unknown
