Redis – How to Remove Slave from Replication with Sentinel

redisreplication

I have a 3-nodes Redis replication and a 3-nodes Sentinel. I want to remove one slave.

I tried stop slave and remove slaveof 10.128.130.139 6379 from configuration. But it became slave again after I started it. And slaveof was back again in config.

After reading SLAVEOF, I tried invoking SLAVEOF NO ONE. But it became slave again after 1 min.

I guess Sentinel reconfig it to slave. How can I remove one slave in my case where Sentinel exists?

Best Answer

I should read sentinel doc carefully. It's mentioned in sections Adding or removing Sentinels and Removing the old master or unreachable slaves.

These are steps:

  • Shut down the redis slave to be removed.
  • Remove slaveof statement from conf

    # Generated by CONFIG REWRITE
    slaveof 10.128.130.139 6379
    
  • Send a SENTINEL RESET mastername command to all Sentinel instances. One after the other, waiting at least 30 seconds between instances.

Now the redis slave is standalone, and sentinels forget this slave.