redisredis-clusterredis-cliredis-server

Correct shutdown sequence for Redis cluster


Suppose I have the following Redis replication setup:

What would be the correct sequence and commands to gracefully shutdown this setup, all while keeping the existing master as master and existing slaves as slaves (meaning, no failover or reconfig should take place)

Thanks.


Solution

  • Shutdown sequence

    You should shutdown sentinels first, to avoid alarms/notifications and failover. Then you can shutdown slaves and master.

    Shutdown command

    You can gracefully shutdown Redis instances (sentinel, slave and master) with the shutdown command.

    For Redis version older than 3.0 (not very sure), there's no shutdown command for Redis sentinel. But you can just use killall or kill -9 process_id to kill it without any side effect.

    ============================================================================

    UPDATE

    In my original answer, I suggested shutdown slaves and master first, to avoid alarms from sentinel. In fact, there's another way to avoid alarms. You can simply remove the master from sentinel before shutdown the master: SENTINEL REMOVE <name>. After removing the master, you don't need to care the shutdown order any more.

    How about the startup order?

    If you use SENTINEL MONITOR <name> <ip> <port> <quorum> command to dynamically add a master to monitor, you can startup sentinel, and add masters dynamically. Instead, if you add the master with sentinel's configuration file, you can startup Redis first, to avoid alarms from sentinel.