redis 单机版 报错:READONLY You can't write against a read only replica

报错原文:

Caused by: redis.clients.jedis.exceptions.JedisDataException: READONLY You can't write against a read only replica.
	at redis.clients.jedis.Protocol.processError(Protocol.java:135)
	at redis.clients.jedis.Protocol.process(Protocol.java:169)
	at redis.clients.jedis.Protocol.read(Protocol.java:223)
	at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:352)
	at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:270)
	at redis.clients.jedis.BinaryJedis.setex(BinaryJedis.java:906)
	at redis.clients.jedis.commands.BinaryJedisCommands.setex(BinaryJedisCommands.java:99)
	at org.springframework.data.redis.connection.jedis.JedisStringCommands$$Lambda$934/000000000000000000.apply(Unknown Source)
	at org.springframework.data.redis.connection.jedis.JedisInvoker.lambda$from$20(JedisInvoker.java:299)
	at org.springframework.data.redis.connection.jedis.JedisInvoker$$Lambda$939/000000000000000000.apply(Unknown Source)
	at org.springframework.data.redis.connection.jedis.JedisInvoker$$Lambda$942/000000000000000000.apply(Unknown Source)
	at org.springframework.data.redis.connection.jedis.JedisConnection.lambda$doInvoke$2(JedisConnection.java:181)
	at org.springframework.data.redis.connection.jedis.JedisConnection$$Lambda$948/000000000000000000.apply(Unknown Source)
	at org.springframework.data.redis.connection.jedis.JedisConnection.doWithJedis(JedisConnection.java:824)
	... 97 common frames omitted

网上查资料,好多说是集群连接到了从节点。但我这个是单机版,明显不是这个问题。
后来找到一篇,修改配置(redis.conf)replica-read-only yes改为no,重启后正常(有待持续观察)。

这个解决结果有待观察,因为之前连接一直没问题,今天第一次遇到,服务器很长时间都没有变更过。有可能只是重启也能恢复~

posted @ 2022-10-25 22:42  流失的痕迹  阅读(4907)  评论(0编辑  收藏  举报