from rediscluster import StrictRedisCluster conn_list = [{"host": "x.x.x.x", "port": 7000},{"host": "x.x.x.x", "port": 7001}, {"host": "x.x.x.x", "port": 7002},{"host": "x.x.x.x", "port": 7003},{"host": "x.x.x.x", "port": 7004}, {"host": "x.x.x.x", "port": 7005}] redis_server = StrictRedisCluster(startup_nodes=conn_list) print(redis_server.keys())
在进行测试连接时报连接127.0.0.1错误,但我传的是服务器的ip,最终定位到
cluster_slots0 = r.execute_command("cluster", "slots")
这句出了问题,文件位于rediscluster下的nodemanager.py,
修改源码为
cluster_slots0 = r.execute_command("cluster", "slots") cluster_slots=[] for i in cluster_slots0: i[2][0] = node["host"] i[3][0] = node["host"] cluster_slots.append(i) import os print('cluster_slots:',os.path.abspath(__file__))