首页 > 技术文章 > 错误解决:redis.exceptions.ResponseError: unknown command 'SENTINEL'

qumogu 2020-10-14 18:21 原文

在python连接redis的哨兵集群时,报如下错误,redis.exceptions.ResponseError: unknown command 'SENTINEL'

原因,python连接redis的哨兵模式,直接连接redis主服务器的ip和端口,192.168.1.23, 6379

redis的哨兵模式与其他mongodb的副本集模式,连接模式不一样,所以习惯思维

实际上redis的哨兵模式,有专门的服务和端口,和redis的服务是完全分开的"192.168.1.24",26379

from redis.sentinel import Sentinel

sentinel_list = [("192.168.1.23",26379),("192.168.1.24",26379)  #这里是哨兵服务器启动的IP和端口
my_sentinel = Sentinel(sentinel_list)

推荐阅读