python 连接 redis cluster 集群
一. redis集群模式有多种, cluster模式只是其中的一种实现方式, 其原理请自行谷歌或者百度, 这里只举例如何使用Python操作 redis cluster 集群
二. python 连接 redis cluster 集群
第三方库:
redis-py-cluster: 最近还在维护
rediscluster: 似乎很久没有更新了
pip install redis-py-cluster
or
pip install rediscluster
from rediscluster import StrictRedisCluster # redis cluster 集群最少三主三从
startup_nodes = [
{"host":"192.168.3.25", "port":6379}, # 主
{"host":"192.168.3.25", "port":7001}, # 6379的从数据库
{"host":"192.168.3.25", "port":6380}, # 主
{"host":"192.168.3.25", "port":7002}, # 6380的从数据库
{"host":"192.168.3.25", "port":6381}, # 主
{"host":"192.168.3.25", "port":7003} # 6381的从数据库
] # 连接集群
conn = StrictRedisCluster(startup_nodes=startup_nodes, decode_responses=True)
conn.set('name', 'lowman')
conn.set('kind', '屌丝')
conn.set('money', '3块8')
print("My name is: ", conn.get('name'))
print "I have money: ", conn.get('money')
其他的各项操作方法与 python 的 redis 库保持一致. startup_nodes 参数中即使存在 错误节点参数 也能连接成功: 理论上, 只要保证有一个节点参数正确就可以正常连接
python 连接 redis cluster 集群的更多相关文章
- python连接redis哨兵集群
一.redis集群模式有多种, 哨兵模式只是其中的一种实现方式, 其原理请自行谷歌或者百度 二.python 连接 redis 哨兵集群 1. 安装redis包 pip install redis 2 ...
- python连接redis sentinel集群
安装 python redis 客户端 pip install redis #!/usr/bin/env python # -*- coding:utf-8 -*- #!/usr/bin/env py ...
- Redis Cluster集群搭建与配置
Redis Cluster是一种服务器sharding分片技术,关于Redis的集群方案应该怎么做,请参考我的另一篇博客http://www.cnblogs.com/xckk/p/6134655.ht ...
- Redis Cluster集群搭建与应用
1.redis-cluster设计 Redis集群搭建的方式有多种,例如使用zookeeper,但从redis 3.0之后版本支持redis-cluster集群,redis-cluster采用无中心结 ...
- Redis cluster集群:原理及搭建
Redis cluster集群:原理及搭建 2018年03月19日 16:00:55 阅读数:6120 1.为什么使用redis? redis是一种典型的no-sql 即非关系数据库 像python的 ...
- Redis Cluster 集群使用(3)
简介 Redis3.0版本之前,可以通过Redis Sentinel(哨兵)来实现高可用(HA),从3.0版本之后,官方推出了Redis Cluster,它的主要用途是实现数据分片(Data Shar ...
- jedis处理redis cluster集群的密码问题
环境介绍:jedis:2.8.0 redis版本:3.2 首先说一下redis集群的方式,一种是cluster的 一种是sentinel的,cluster的是redis 3.0之后出来新的集群方式 本 ...
- Redis Cluster集群主从方案
本文介绍一种通过Jedis和Cluster实现Redis集群(主从)的高可用方案,该方案需要使用Jedis2.8.0(推荐),Redis3.0及以上版本(强制). 附:Redis Cluster集群主 ...
- 【精】搭建redis cluster集群,JedisCluster带密码访问【解决当中各种坑】!
转: [精]搭建redis cluster集群,JedisCluster带密码访问[解决当中各种坑]! 2017年05月09日 00:13:18 冉椿林博客 阅读数:18208 版权声明:本文为博主 ...
随机推荐
- spark 操作hive
1.hive动态分区,只需进行以下设置 val spark = SparkSession.builder() .appName("hivetest") .master(" ...
- Centos修改swap分区大小
1. 查看当前分区情况 free -m 2. 增加swap大小 dd if=/dev/zero of=/var/swap bs=1024 count=12288000 #增加12G空间 3. 设置交换 ...
- .net core 在 View 中使用 Jquery 无效问题
问题描述: 在 View 视图中使用模板 _Layout.cshtml,其中模板已经调用了 Jquery.js ,但是在 View 视图下写 js 无效.后来通过浏览器查看自己写的 js 压根没加载出 ...
- 用FTPClient,执行到ftp.storeFile(fileName, inputFile);无反应了
Q:用FTPClient,执行到ftp.storeFile(fileName, inputFile):无反应了 A: ftpclient.enterLocalPassiveMode(); ftp. ...
- TP5多字段排序
有业务需求如下: select * from table where id IN (3,6,9,1,2,5,8,7) order by field(id,3,6,9,1,2,5,8,7); 这里直入主 ...
- golang学习笔记--函数和方法
在go中,函数类型是一等类型,这意味着可以吧函数当做一个值来传递和使用. func divide(dividend int,divisor int)(int,error){ //省略部分代码 } 参数 ...
- (10)ASP.NET Core 中的环境(Environments:dev, stage, prod)
1.环境变量配置 ASP.NET Core在应用程序启动时读取环境变量(Properties\launchSettings.json)ASPNETCORE_ENVIRONMENT,并将该值存储在IHo ...
- java中多重循环和break、continue语句
一.嵌套循环 循环可以互相嵌套,以实现更加复杂的逻辑,其代码的复杂程度也会提高,对初学者而言这应该是个难点,下面我们通过一些例子说明嵌套循环的使用,读者要自己把这些代码上机练习,并理解程序运行的流程. ...
- JAAS configuration for Kafka clients
Clients may configure JAAS using the client configuration property sasl.jaas.config or using the sta ...
- MVC伪静态路由简单搭配
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute ...