1.redis模块
python里的redis库不支持redis集群操作,写个简单的代码测试一下:
import redis
r =redis.StrictRedis(host='192.168.222.66',port=6379)
r.set("name","Tom")
print(r.get("name"))
结果报了如下异常:redis.exceptions.ResponseError: MOVED 12285 192.168.222.66:6384
...
File "/Library/Python/2.7/site-packages/redis/connection.py", line 582, in read_response
raise response
redis.exceptions.ResponseError: MOVED 12285 192.168.222.66:6384
2.redis-py-cluster模块
2.1安装
pip3 install redis-py-cluster
2.2 连接redis集群
示例代码:
from rediscluster import RedisC