DBAtlas · Database operations atlas

Perform a manual failover with Sentinel and clean up the topology

RedisSentinel

Command

# First check quorum and an eligible replica:
redis-cli -p 26379 SENTINEL CKQUORUM mymaster
redis-cli -p 26379 SENTINEL REPLICAS mymaster
# Manual failover without waiting for agreement from other sentinels:
redis-cli -p 26379 SENTINEL FAILOVER mymaster
# Verify the new master (must be the same on all sentinels):
redis-cli -p 26379 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster
# If old/removed replicas remain listed, reset sentinels one at a time, 30 s apart:
redis-cli -p 26379 SENTINEL RESET mymaster

What it does

Hands the master role to the most suitable replica even when the master is healthy; then verifies the new master and clears replicas that no longer exist from the sentinels' memory.

When to use it

Before planned maintenance on the master's host, during a failover drill, or when moving the master to another data center.

Caution

There is a write interruption of a few seconds during failover, and data written to the master but not yet replicated can be lost. Replicas with replica-priority 0 are never chosen; if no eligible replica exists the command returns an error. If SENTINEL RESET runs on all sentinels at once, topology information is lost temporarily; run it on each one separately and spaced out. Make sure clients use a driver that asks Sentinel for the master address.

Open in DBAtlas →

Related