1. 安装依赖
pip install redis-py-cluster
2. 连接集群
from rediscluster import RedisCluster
r = RedisCluster(startup_nodes=[{"host": "192.168.1.101", "port": 6381},{"host": "192.168.1.102", "port": 6379}], password='123456')
3. 检查连接
r.ping()
参考: python 操作redis集群