首先安装python支持的redis模块
pip install redis==2.10.6
pip install redis-py-cluster==1.3.5
代码如下
from rediscluster import RedisCluster
conn_list = [
{'host':'192.168.88.161', 'port':6371},
{'host':'192.168.88.161', 'port':6372},
{'host':'192.168.88.161', 'port':6373},
{'host':'192.168.88.161', 'port':6374},
{'host':'192.168.88.161', 'port':6375},
{'host':'192.168.88.161', 'port':6376},
]
conn = RedisCluster(startup_nodes=conn_list, decode_responses=True, password=123456)
print conn
输出结果
RedisCluster<192.168.88.161:6371, 192.168.88.161:6372, 192.168.88.161:6373, 192.168.88.161:6374, 192.168.88.161:6375, 192.168.88.161:6376>



