Skip to content Skip to sidebar Skip to footer

How To Failover To New Master Node When Using Redis With Sentinel And Redis-py?

To subscribe to Sentinel failover, what is the name of the Channel, and how do I detect that I need to refresh the master in the subscribed function? I have a multi node Redis setu

Solution 1:

To achieve this, you will want to subscribe to the sentinel, not the master node. The channel you are looking for is "+switch-master". The Sentinel documentation indicates the channel as "switch-master" "without the +", but as of 3.2.4 the + is included.

Redis Sentinel Pub/Sub Message Docs

You should be able to reference the redis-py docs for the rest. Redis-py Docs


UPDATE

You could also consider using the client-reconfig-script setting.

When the master changed because of a failover a script can be called in order to perform application-specific tasks to notify the clients that the configuration has changed and the master is at a different address.

http://download.redis.io/redis-stable/sentinel.conf

Hope that helps


Post a Comment for "How To Failover To New Master Node When Using Redis With Sentinel And Redis-py?"