Python连接redis哨兵问题
from redis.sentinel import Sentinelsentinel = Sentinel([('47.245.11.164', 26379),
('47.74.8.73', 26379),
('47.74.3.64', 26379)],
socket_timeout=0.5)
master = sentinel.discover_master('mymaster')
print(master)
slave = sentinel.discover_slaves('mymaster')
print(slave)
master = sentinel.master_for('mymaster', socket_timeout=3, db=3)
master.set("name1", "abc")
按照网上的例子写的。但是到最后一句的时候就出现,前面的discover_master都是可以正常显示打印的.
raise TimeoutError("Timeout connecting to server")
redis.exceptions.TimeoutError: Timeout connecting to server
连接超时,检查一下redis服务是否正常。
页:
[1]