Python3 redis集群连接 (带密码验证)
发布时间:2020-12-20 12:45:41 所属栏目:Python 来源:网络整理
导读:环境: python 3.7.4 redis集群 单集群(无slave) 很多文章都说redis密码,今天验证的了很多次失败,查了相关资料有才知道连接方式,一下为代码,修改123456为自己代码就可以使用了 from rediscluster import StrictRedisClusterlist = [ ‘02200000001‘,‘0
环境:
python 3.7.4 redis集群 单集群(无slave) 很多文章都说redis密码,今天验证的了很多次失败,查了相关资料有才知道连接方式,一下为代码,修改123456为自己代码就可以使用了 from rediscluster import StrictRedisCluster list = [ ‘02200000001‘,‘02200000002‘,‘02200000003‘,‘02200000004‘,‘02200000005‘,‘02200000006‘,‘02200000007‘,‘02200000008‘,‘02200000009‘,‘02200000010‘ ] def redis_cluster(): redis_nodes = [ {‘host‘:‘192.168.0.56‘,‘port‘:7001},{‘host‘:‘192.168.0.56‘,‘port‘:7002},‘port‘:7003},] # print(redis_nodes[1]) try: redisconn = StrictRedisCluster(startup_nodes=redis_nodes,password=‘123456‘) print(redisconn) # redisconn.set(‘yyy‘,‘tttt‘) # A=redisconn.set(‘yyy‘) # print(A) except: print(‘error‘) for i in range(0,len(list)): redisconn.set(‘user_phone_‘+list[i],‘222221‘) print(redisconn.get(‘user_phone_‘+list[i])) redis_cluster() (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 是否有一个框架可用于针对多个版本的Python测试Python模块?
- heapq 对有序的数组列表进行整体排序
- python – 在Matplotlib直方图或Seaborn distplots的箱子上
- python – 在while循环中生成绘图后在KeyboardInterrupt上退
- python joblib并行在Windows上工作甚至“如果__name__ ==’
- 都说 Python 赶超 Java,爬取拉勾网数据发现它的薪资已高至
- Django转向PostgreSQL无法导入数据,说明数据太长
- 执行生成器表达式的最pythonic方法是什么?
- python-3.x – 绘图时的Matplotlib索引错误
- Python:认识模块