qq_28207959 2017-09-22 06:25 采纳率: 0%
浏览 5718

redis远程连接报错(Too many Cluster redirections)

最近搭建redis集群环境,一直在报Too many Cluster redirections的错误。
具体信息如下:
1、redis集群搭建在同一台阿里云的ECS服务器上,使用端口为7001~7006,三主三从;
2、ECS安全策略以及ubuntu内部防火墙均已经开通;
3、redis配置文件中bind的是网卡的实际IP(非公网IP),运行集群脚本也是用的网卡的实际IP;
4、从ECS上通过内网IP和公网IP都可以连接redis集群,从本地可以通过Redis DesktopManager连接集群并成功读写;
5、用JedisCluster操作Redis则报错(Too many Cluster redirections);
6、搜索过这个问题的报错解决方法,基本都是因为bind了127.0.0.1,但是我已经bind了网卡的IP了,启动集群也用的是网卡IP。
请各位大神帮忙看看还有什么原因会导致这个问题,我悬赏分没有了,还请大神们施舍答案,谢谢。

java代码:
JedisPoolConfig poolConfig = new JedisPoolConfig();

// 最大连接数

poolConfig.setMaxTotal(1);

// 最大空闲数

poolConfig.setMaxIdle(1);

// 最大允许等待时间,如果超过这个时间还未获取到连接,则会报JedisException异常:

// Could not get a resource from the pool

poolConfig.setMaxWaitMillis(1000);

Set nodes = new LinkedHashSet();

nodes.add(new HostAndPort("x.x.x.x", 7001));

nodes.add(new HostAndPort("x.x.x.x", 7002));

nodes.add(new HostAndPort("x.x.x.x", 7003));

nodes.add(new HostAndPort("x.x.x.x", 7004));

nodes.add(new HostAndPort("x.x.x.x", 7005));

nodes.add(new HostAndPort("x.x.x.x", 7006));

JedisCluster cluster = new JedisCluster(nodes, poolConfig);

String name = cluster.get("name");

System.out.println(name);

cluster.set("age", "18");

System.out.println(cluster.get("age"));

try {

cluster.close();

} catch (Exception e) {

e.printStackTrace();

}

  • 写回答

5条回答 默认 最新

  • yinyanji 2018-08-29 05:46
    关注

    兄弟,我和你一样很困扰,请问你搞定了吗?我现在还很困扰,他妈的网上什么破资料都没有,都他妈的瞎几把说的五花八门的,没实际效果。

    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献