yangzhi_java 2016-03-25 04:26 采纳率: 0%
浏览 40675

关于redis集群 no reachable node in cluster的错误

代码如下
private static JedisCluster jedisCluster = null;
static{
Set nodes = new HashSet<>();
nodes.add(new HostAndPort("114.112.69.204", 7001));
nodes.add(new HostAndPort("114.112.69.204", 7002));
nodes.add(new HostAndPort("114.112.69.204", 7003));
nodes.add(new HostAndPort("114.112.69.204", 7004));
nodes.add(new HostAndPort("114.112.69.204", 7005));
nodes.add(new HostAndPort("114.112.69.204", 7006));
// 1、创建一个JedisCluster对象,构造方法,需要指定一个Set对象,set中包含HostAndPort对象。每个HostAndPort就是一个节点的地址。
jedisCluster = new JedisCluster(nodes);
/*JedisPoolConfig config = new JedisPoolConfig();
config.setMaxActive(1000);
config.setMaxIdle(300);
config.setMaxWait(10000);
config.setTestOnBorrow(false);
jedisPool =new JedisPool(config, "114.112.69.204", 6379);*/
}
@RequestMapping("/index.html")
@ResponseBody
//加入redis缓存
public Map index(HttpServletRequest request, HttpServletResponse response) throws IOException {

    Map<String, Object> result = new HashMap<String, Object>();
    ObjectMapper objectMapper = new ObjectMapper();
    IndexResult indexResult = null;
    String indexJson = jedisCluster.hget("indexResult_KEY","indexResult666");
    if (StringUtils.isNotBlank(indexJson)) {
        try {//取出redis中的数据
            indexResult = objectMapper.readValue(indexJson, IndexResult.class);
        } catch (JsonParseException e) {

            e.printStackTrace();
        } catch (JsonMappingException e) {

            e.printStackTrace();
        } catch (IOException e) {

            e.printStackTrace();
        }finally{
            if (jedisCluster != null) {
                jedisCluster.close();
            }
        }
在正常请求时会报错!!!!主要错误如下
严重: Servlet.service() for servlet [goutrip_api] in context with path [] threw exception [Request processing failed; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: no reachable node in cluster] with root cause

redis.clients.jedis.exceptions.JedisConnectionException: no reachable node in cluster
at redis.clients.jedis.JedisSlotBasedConnectionHandler.getConnection(JedisSlotBasedConnectionHandler.java:54)
at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:113)
at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:131)
at redis.clients.jedis.JedisClusterCommand.run(JedisClusterCommand.java:30)
at redis.clients.jedis.JedisCluster.hget(JedisCluster.java:361)
at com.goutrip.controller.index.IndexController.index(IndexController.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)

而使用命令行取出数据是没有问题的
![图片说明](https://img-ask.csdn.net/upload/201603/25/1458879946_317708.png)

要崩溃了啊!!!!快来救救我!!!!!!!!
  • 写回答

5条回答 默认 最新

  • yangzhi_java 2016-03-25 09:44
    关注

    问题已经解决了,就是包的冲突

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)