当前位置:   article > 正文

redis连接异常 redis.clients.jedis.exceptions.JedisClusterException: CLUSTERDOWN The cluster is down

redis.clients.jedis.exceptions.jedisclusterexception: clusterdown the cluste

遇到一个问题,因为是在测试环境,之前退出使用的kill -9暴力方式,再重新启动redis集群的时候,先并没有恢复rdb和aof,使用redis-cli客户端可以连接,说明集群已经启动来了,但是使用jedis客户端代码连接不上,抛异常:

Exception in thread "main" redis.clients.jedis.exceptions.JedisClusterException: CLUSTERDOWN The cluster is down
    at redis.clients.jedis.Protocol.processError(Protocol.java:126)
    at redis.clients.jedis.Protocol.process(Protocol.java:166)
    at redis.clients.jedis.Protocol.read(Protocol.java:220)
    at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:318)
    at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:255)
    at redis.clients.jedis.Connection.getBulkReply(Connection.java:245)
    at redis.clients.jedis.Jedis.get(Jedis.java:181)
    at redis.clients.jedis.JedisCluster$3.execute(JedisCluster.java:161)
    at redis.clients.jedis.JedisCluster$3.execute(JedisCluster.java:158)
    at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:106)
    at redis.clients.jedis.JedisClusterCommand.run(JedisClusterCommand.java:25)
    at redis.clients.jedis.JedisCluster.get(JedisCluster.java:163)
    at com.study.cache.JedisTest.main(JedisTest.java:17)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

重启redis集群,重试不行,还是报相同的错;

把每个redis节点下面的rdb和aof都删除(如果是生产环境谨慎操作),重启redis集群,用jedis客户端代码也可以连接了,没有抛异常;

cd D:\Redis\Redis6379

redis-server.exe --service-stop --service-name Redis6379
redis-server.exe --service-stop --service-name Redis6380
redis-server.exe --service-stop --service-name Redis6381
redis-server.exe --service-stop --service-name Redis6382
redis-server.exe --service-stop --service-name Redis6383
redis-server.exe --service-stop --service-name Redis6384

redis-server.exe --service-start --service-name Redis6379
redis-server.exe --service-start --service-name Redis6380
redis-server.exe --service-start --service-name Redis6381
redis-server.exe --service-start --service-name Redis6382
redis-server.exe --service-start --service-name Redis6383
redis-server.exe --service-start --service-name Redis6384

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

代码正常运行

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/638423
推荐阅读
相关标签
  

闽ICP备14008679号