Redis常见错误

转载:

redis:CLUSTER cluster is down 解决方法:https://blog.csdn.net/qq_35066345/article/details/79833609

集成redis集群错误:redis.clients.jedis.exceptions.JedisDataException: ERR This instance has cluster support disabled
解决办法: 

修改redis.config,添加cluster-enabled yes

连接Redis异常:JedisMovedDataException:https://zdran.com/20180518.html

环境

java API连接redis
出现下面的异常信息:

redis.clients.jedis.exceptions.JedisMovedDataException: MOVED 1539 127.0.0.1:6379

解决方案

将连接对象从 Jedis 换成 JedisCluster。就可以了。

问题原因

MOVED表示使用的是Redis群集。而 Jedis 不是集群模式。

//import redis.clients.jedis.HostAndPort;
//import redis.clients.jedis.JedisCluster;

HostAndPort hostAndPort = new HostAndPort(host, port);
Set<HostAndPort> hostAndPortSet = new HashSet<>();
hostAndPortSet.add(hostAndPort);
JedisCluster jedis = new JedisCluster(hostAndPortSet);
jedis.setnx(key, value);

猜你喜欢

转载自blog.csdn.net/u010170616/article/details/80863973