Python 如何使用redis.py运行sentinel命令
是否可以使用python运行sentinel命令,如Python 如何使用redis.py运行sentinel命令,python,redis,redis-sentinel,Python,Redis,Redis Sentinel,是否可以使用python运行sentinel命令,如sentinel masters?链接是 在使用sentinel.master_for(“master_name”)之前,我必须知道master name,但是我使用的redis服务是由公司的privite云平台提供的,sentinel conf中的master name包含当前master节点的ip,如果master节点发生变化,就会被重写和更改,所以硬编码是不可能的 目前,我的一个想法是将频道\uuuu sentinel\uuuu:hell
sentinel masters
?链接是
在使用sentinel.master_for(“master_name”)之前,我必须知道master name,但是我使用的redis服务是由公司的privite云平台提供的,sentinel conf中的master name包含当前master节点的ip,如果master节点发生变化,就会被重写和更改,所以硬编码是不可能的
目前,我的一个想法是将频道\uuuu sentinel\uuuu:hello
分为子频道,并从中解析主机名,但是,这看起来很不舒服
有没有其他方法可以获取主控名称?在终端中,我们可以使用redis cli连接sentinel,并使用sentinel masters获取master信息,这可以在python中完成吗?
redis.py
本身可以用于连接sentinel
import redis
sentinel_obj = redis.Redis(host="127.0.0.1", port=26379) # pass the host and port of sentinel
sentinel_obj.sentinel_masters() # this will get all available master-group-names in sentinel