Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用redis.py运行sentinel命令_Python_Redis_Redis Sentinel - Fatal编程技术网

Python 如何使用redis.py运行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

是否可以使用python运行sentinel命令,如
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