当我按照此处的部署指南链接: https://docs.bitnami.com/tutorials/deploy-redis-sentinel-production-cluster/ 尝试连接到主 Redis Sentinel 节点时,我遇到了 MasterNotFoundError 错误。
我的连接到主 Redis Sentinel 节点的代码如下:
from redis.sentinel import Sentinel
redis_host = 'redis.default.svc.cluster.local'
redis_port = 26379
sentinel = Sentinel([(redis_host, redis_port)], socket_timeout=0.1, password='abc')
redis_client = sentinel.master_for('mymaster', password='abc')
在他们的GitHub存储库中,我看到sentinel.masterSet的配置默认设置为mymaster。但是,当我尝试使用下面的代码递增时:
redis_client.incr('counter', 1)
我遇到了redis.sentinel.MasterNotFoundError: No master found for 'mymaster'的错误。
我应该如何解决这个问题?谢谢。