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

关于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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序