Redis Sentinel Commands

redis-py can be used together with Redis Sentinel to discover Redis nodes. You need to have at least one Sentinel daemon running in order to use redis-py’s Sentinel support.

Connection example (assumes redis redis on the ports listed below):

>>> from redis import Sentinel
>>> sentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1)
>>> sentinel.discover_master('mymaster')
('', 6379)
>>> sentinel.discover_slaves('mymaster')
[('', 6380)]
class redis.commands.sentinel.SentinelCommands[source]

A class containing the commands specific to redis sentinal. This class is to be used as a mixin.


Redis Sentinel’s SENTINEL command.


Check if the current Sentinel configuration is able to reach the quorum needed to failover a master, and the majority needed to authorize the failover.

This command should be used in monitoring systems to check if a Sentinel deployment is ok.


Force a failover as if the master was not reachable, and without asking for agreement to other Sentinels (however a new version of the configuration will be published so that the other Sentinels will update their configurations).


Force Sentinel to rewrite its configuration on disk, including the current Sentinel state.

Normally Sentinel rewrites the configuration every time something changes in its state (in the context of the subset of the state which is persisted on disk across restart). However sometimes it is possible that the configuration file is lost because of operation errors, disk failures, package upgrade scripts or configuration managers. In those cases a way to to force Sentinel to rewrite the configuration file is handy.

This command works even if the previous configuration file is completely missing.


Returns a (host, port) pair for the given service_name


Returns a dictionary containing the specified masters state.


Returns a list of dictionaries containing each master’s state.

sentinel_monitor(name, ip, port, quorum)[source]

Add a new master to Sentinel to be monitored


Remove a master from Sentinel’s monitoring


This command will reset all the masters with matching name. The pattern argument is a glob-style pattern.

The reset process clears any previous state in a master (including a failover in progress), and removes every slave and sentinel already discovered and associated with the master.


Returns a list of sentinels for service_name

sentinel_set(name, option, value)[source]

Set Sentinel monitoring parameters for a given master


Returns a list of slaves for service_name