参考文档

http://redis.readthedocs.org/en/latest/topic/cluster-tutorial.html#id5

http://blog.csdn.net/myrainblues/article/details/25881535

集群的客户端命令为 redis-cli -c -p 7000 , 必须带  -c 否则认为是普通的redis客户端

普通命令测试如下

检查slave 和 master的关系 , slave 和 master 是主从关系,实时备份, 这是跟 codis 的一个很大的不同,codis 的 slave 和 master 数据不同步,属于主备关系

同样不支持 mget 这种批量处理类型的命令

所有的master 节点 相对于客户端而言是等价的,如下图

客户端 Jedis 的使用 ( Jedis 2.6.2 版本)

    @Test
public void testRedis300() {
Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
jedisClusterNodes.add(new HostAndPort("192.168.10.229", ));
//jedisClusterNodes.add(new HostAndPort("192.168.10.229", 7002));
//jedisClusterNodes.add(new HostAndPort("192.168.10.229", 7003));
JedisCluster jc = new JedisCluster( jedisClusterNodes );
String t1 = jc.get("t_1");
System.out.println("t=" + t1); Map<String, JedisPool> map = jc.getClusterNodes();
for ( String k: map.keySet()) {
Jedis jedis = null;
JedisPool p = map.get( k );
try {
jedis = p.getResource();
t1 = p.getResource().get("t_1");
} catch (Exception e) {
p.returnBrokenResource( jedis );
jedis = null;
// TODO: handle exception
} finally{
if( jedis != null ){
p.returnResource( jedis );
}
}
System.out.println("k=" + k + ",t1=" + t1);
}
Assert.assertTrue(true);
}

结果如下

t=
k=192.168.10.229:,t1=
k=192.168.10.229:,t1=
k=192.168.10.229:,t1=
k=192.168.10.229:,t1=
k=192.168.10.229:,t1=
k=192.168.10.229:,t1=

jedis客户端的坑.

1)cluster环境下redis的slave不接受任何读写操作,

2)client端不支持keys批量操作,不支持select dbNum操作,只有一个db:select 0

3)JedisCluster 的info()等单机函数无法调用,返回(No way to dispatch this command to Redis Cluster)错误,.

4)JedisCluster 没有针对byte[]的API,需要自己扩展(附件是我加的基于byte[]的BinaryJedisCluster  api)

redis 3.0 集群__使用的更多相关文章

  1. redis 3.0 集群__数据迁移和伸缩容

    添加节点 1,启动2个新的redis-sever, 参照 ( redis 3.0 集群____安装 ),端口号为 7007 和 7008 2,使用命令 redis-trib.rb add-node 命 ...

  2. redis 3.0 集群__配置文件详解(常用配置)

    参考文档 http://www.cnblogs.com/huangjacky/p/3700473.html http://www.cnblogs.com/cxd4321/archive/2012/12 ...

  3. redis 3.0 集群__安装

    参考文档 http://redis.io/topics/cluster-tutorial http://redis.io/topics/cluster-spec http://redis.readth ...

  4. redis 3.0 集群__故障测评

    一, slave 是不能通过redis-cli 直接进行读写操作的,但是可以执行 keys, info 命令( 猜测类似全局性的不影响到原子性操作的命令应该都可以,没有一一试验) 二,集群中的某节点异 ...

  5. redis 3.0 集群__监控警报工具(sentinel)

    参考文档 http://redis.readthedocs.org/en/latest/topic/sentinel.html 因为目前还处于开发阶段,就先不研究了,待续

  6. Redis 3.0 集群搭建

    Redis 3.0 集群搭建 开启两个虚拟机 分别在两个虚拟机上开启3个Redis实例 3主3从两个虚拟机里的实例互为主备 下面分别在两个虚拟机上安装,网络设置参照codis集群的前两个主机 分别关闭 ...

  7. Redis 3.0集群 Window搭建方案

    Redis 3.0集群 Window搭建方案 1.集群安装前准备 安装Ruby环境,安装:rubyinstaller-2.3.0-x64.exe http://dl.bintray.com/onecl ...

  8. Redis 5.0 集群搭建

    Redis 5.0 集群搭建 单机版的 Redis 搭建 https://www.jianshu.com/p/b68e68bbd725 /usr/local/目录 mkdir redis-cluste ...

  9. 国际站中国区,孟买上Redis 4.0 集群版

    信息摘要: 国际站中国区,孟买上线Redis 4.0 集群版适用客户: 所有用户版本/规格功能: redis 4.0 集群版产品文档: https://www.alibabacloud.com/hel ...

随机推荐

  1. 解剖Nginx·模块开发篇(5)解读内置非默认模块 ngx_http_stub_status_module

    1 Background ngx_http_stub_status_module 是一个 Nginx 的内置 HTTP 模块,该模块可以提供 Nginx 的状态信息.默认情况下这个模块是不被编译进来的 ...

  2. H5 继承

    继承 CSS的某些样式是具有继承性的,那么什么是继承呢?继承是一种规则,它允许样式不仅应用于某个特定html标签元素,而且应用于其后代.比如下面代码:如某种颜色应用于p标签,这个颜色设置不仅应用p标签 ...

  3. 404. Sum of Left Leaves 左叶子之和

    [抄题]: Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are ...

  4. c# 类中使用ResolveUrl

    类中使用ResolveUrl 1>获取当前page然后调用ResolveUrl System.Web.UI.Page page = HttpContext.Current.CurrentHand ...

  5. springboot+beetlsql+mysql整合

    一.工程目录结构 二.pom.xml文件配置 <dependency> <groupId>mysql</groupId> <artifactId>mys ...

  6. [C++] 2D Array's memory allocation

    2D Array's memory allocation

  7. c#反射泛型方法

    private void GetByEnumType() { var EnumType = Context.Request["EnumType"] ?? ""; ...

  8. 42 :809*x=800*x+9*x+1

    题目:809*x=800*x+9*x+1(去掉最后的1有解)其中x代表的两位数,8*x的结果为两位数,9*x的结果为3位数.求x代表的两位数,及809*x后的结果(两种方法实现) public cla ...

  9. 36 有n个整数,使其前面各数顺序向后移n个位置,最后m个数变成最前面的m个数

    题目:有n个整数,使其前面各数顺序向后移n个位置,最后m个数变成最前面的m个数 public class _036ExchangeSite { public static void main(Stri ...

  10. SQLServer学习-- Microsoft SQL Server 2008 Management Studio Express

    Microsoft SQL Server 2008 Management Studio Express is a free, integrated environment for accessing, ...