zoukankan      html  css  js  c++  java
  • redis集群出现JedisNoReachableClusterNodeException异常(No reachable node in cluster)

    redis.clients.jedis.exceptions.JedisNoReachableClusterNodeException: No reachable node in cluster
        at redis.clients.jedis.JedisSlotBasedConnectionHandler.getConnection(JedisSlotBasedConnectionHandler.java:57)
        at redis.clients.jedis.JedisSlotBasedConnectionHandler.getConnectionFromSlot(JedisSlotBasedConnectionHandler.java:74)
        at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:116)
        at redis.clients.jedis.JedisClusterCommand.run(JedisClusterCommand.java:31)
        at redis.clients.jedis.JedisCluster.get(JedisCluster.java:124)
        at cn.tbnb1.service.redis.RedisCacheService.get(RedisCacheService.java:55)
        at cn.tbnb1.seckil.controller.SeckillController.resultQuery(SeckillController.java:68)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)

    上面是异常,

    经过查找代码终于发现,最终是调用JedisCluster.close()方法造成的。

    原因:我们使用的是redis3.0的集群,用jedis的JedisCluster.close()方法造成的集群连接关闭的情况。 jedisCluster内部使用了池化技术,每次使用完毕都会自动释放Jedis因此不需要关闭。如果调用close方法后再调用jedisCluster的api进行操作时就会出现如上错误。

  • 相关阅读:
    Python记录12:迭代器+生成器+生成式
    Python记录11:叠加多个装饰器+有参装饰器
    Python记录10:模块
    Day7
    Day7
    Day7
    Day7
    Day7
    Day7
    Day7
  • 原文地址:https://www.cnblogs.com/java-synchronized/p/7910716.html
Copyright © 2011-2022 走看看