0
0
Redisquery~10 mins

Sentinel configuration in Redis - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Sentinel configuration
Start Sentinel
Load Config File
Connect to Master
Monitor Master & Slaves
Detect Failover Conditions
If Master Down?
NoContinue Monitoring
Yes
Elect New Master
Reconfigure Slaves
Notify Clients
Continue Monitoring
Sentinel starts, loads config, monitors master and slaves, detects failures, triggers failover, and continues monitoring.
Execution Sample
Redis
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
Configures Sentinel to monitor a master Redis instance and sets failover parameters.
Execution Table
StepActionEvaluationResult
1Start Sentinel processSentinel reads configSentinel ready to monitor
2Load 'sentinel monitor' configIdentify master 'mymaster' at 127.0.0.1:6379Master registered for monitoring
3Load 'down-after-milliseconds'Set timeout to 5000 msFailure detection timer set
4Load 'failover-timeout'Set failover timeout to 60000 msFailover timing configured
5Load 'parallel-syncs'Set max parallel syncs to 1Sync limit set
6Connect to master and slavesConnections establishedMonitoring begins
7Check master healthMaster respondsContinue monitoring
8Simulate master downNo response within 5000 msMark master as down
9Start failover electionSentinels voteNew master elected
10Reconfigure slavesSlaves point to new masterReplication updated
11Notify clientsClients informed of new masterClients reconnect
12Continue monitoringSentinel resumes checksSystem stable
13ExitNo further actionsSentinel runs continuously
💡 Sentinel runs continuously; exit here means end of this trace.
Variable Tracker
VariableStartAfter Step 2After Step 8After Step 9Final
master_statusunknownupdownnew_master_electednew_master_elected
failover_timernot setnot setstartedrunningrunning
slave_configdefaultdefaultdefaultreconfiguredreconfigured
Key Moments - 3 Insights
Why does Sentinel wait 5000 ms before marking the master as down?
Sentinel uses the 'down-after-milliseconds' setting (step 3 and 8) to avoid false alarms from temporary network issues.
How does Sentinel decide who becomes the new master?
Sentinel nodes vote during failover election (step 9) to choose the best candidate, ensuring a coordinated failover.
What happens to the slaves after a new master is elected?
Slaves are reconfigured to replicate from the new master (step 10), so data stays consistent.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does Sentinel mark the master as down?
AStep 8
BStep 9
CStep 7
DStep 10
💡 Hint
Check the 'Evaluation' column for 'No response within 5000 ms' in step 8.
According to variable_tracker, what is the 'master_status' after step 9?
Aup
Bdown
Cnew_master_elected
Dunknown
💡 Hint
Look at the 'master_status' row under 'After Step 9' column.
If 'parallel-syncs' was set to 2 instead of 1, which step would be affected?
AStep 3
BStep 5
CStep 9
DStep 11
💡 Hint
Refer to step 5 where 'parallel-syncs' is loaded and set.
Concept Snapshot
Sentinel configuration commands set monitoring and failover parameters.
Key commands: sentinel monitor, down-after-milliseconds, failover-timeout, parallel-syncs.
Sentinel monitors master and slaves, detects failures, triggers failover.
Failover includes electing new master, reconfiguring slaves, notifying clients.
Sentinel runs continuously to maintain Redis high availability.
Full Transcript
Sentinel configuration involves setting up monitoring for a Redis master instance and defining failover behavior. The process starts by loading configuration commands such as 'sentinel monitor' to specify the master, 'down-after-milliseconds' to set failure detection timeout, 'failover-timeout' for failover duration, and 'parallel-syncs' to limit slave synchronization. Sentinel connects to the master and slaves, continuously checking their health. If the master does not respond within the timeout, Sentinel marks it as down and initiates a failover election among Sentinel nodes. Once a new master is elected, slaves are reconfigured to replicate from it, and clients are notified to reconnect. This cycle repeats to ensure Redis availability.