3

Suppose I have the following Redis replication setup:

  • 3 machines
  • Each machine has a Redis server and a Redis sentinel.
  • One of the servers is set as master, the other two are its slaves.

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.

odedia
  • 931
  • 2
  • 11
  • 27

2 Answers2

2

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.

for_stack
  • 21,012
  • 4
  • 35
  • 48
  • 1
    what Would the startup order be as ? start redis and then start sentinel? – Preethi Jahnavi Nov 08 '19 at 17:14
  • 1
    @PreethiJahnavi Please see my update in the answer. – for_stack Nov 09 '19 at 04:08
  • 1
    Thanks for the second solution. However, my use case is more inclined towards your initial solution since the frequency of restarts is more. I understood the reasoning of shutdown order. For startup, I believe Redis service should be started first and then sentinel service. Is that right? – Preethi Jahnavi Nov 11 '19 at 16:44
  • 1
    @PreethiJahnavi YES, you can start Redis first to avoid alarms. In fact, if you don't care those alarms, you can start either Redis or Sentinel first. Eventually, sentinel will monitor Redis correctly. – for_stack Nov 12 '19 at 00:49
0

I have a redis cluster size of 3 with 6 known nodes( 3 master and 3 slave) on 2 different servers .

In order to shutdown the cluster for any activity on the server you may first gracefully SHUTDOWN the slave with SAVE option in order to avoid issue of cluster remapping and then shutdown master nodes .

  • Login to any node and execute below command to identify master and slave nodes.

    redis-cli -h IP -a PASSWORD -p PORT (replace IP, PASSWORD and PORT of your own)

  • Find master and slave nodes using command

    CLUSTER NODES

  • Login to all slaves one by one and execute below command to shutdown with save option.

    SHUTDOWN SAVE

Once done bring master up and then slave