事情经过是这样,我们使用了阿里云的redis 集群版,今天上班同事告诉我,redis不能正常使用了,控制台有大量以下错误:
NOREAD You can't read against a non-read redis.
详细异常堆栈如下:
org.springframework.dao.InvalidDataAccessApiUsageException: NOREAD You can't read against a non-read redis.; nested exception is redis.clients.jedis.exceptions.JedisDataException: NOREAD You can't read against a non-read redis.
at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:44)
at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:36)
at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:37)
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:37)
at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:210)
at org.springframework.data.redis.connection.jedis.JedisConnection.sMembers(JedisConnection.java:1900)
at org.springframework.data.redis.core.DefaultSetOperations$7.doInRedis(DefaultSetOperations.java:130)
于是乎根据上面堆栈先排查连接配置信息是否正确,然后又分析了半天源码!最后机智如我,直接登录上去看redis的状态,然后来个超级简单的检测命令:set i i
于是报了下面错误:
NOWRITE You can't write against a non-write redis.
这个时候已经很明显了,明显是该redis 集群出问题了,和程序、连接配置都无关。
果断打开阿里云redis控制台,发现redis到期了,被禁止使用了。
续费之后,问题解决。
set ${key} ${value} 报“NOWRITE You can't write against a non-write redis.”错误,那报“NOREAD You can't read against a non-read redis.”错误,就应该是get ${key} 导致的。
NOWRITE You can't write against a non-write redis
DB处于只读状态,主要发生在变配、小版本升级等流程中。
DISABLE You can't write or read against a disable instance
目前处于锁定状态,一般是用户欠费。
redis tempory failure or response big than 500MB
redis请求的value最大不能超过500MB,超过之后返回该错误信息。
node idx is invalid
node num specified >= node count
主要出现在iinfo, riinfo, iscan, imonitor等命令中,用于指定节点的index不在合法范围内。
command keys must in same slot
集群实例中,事务、脚本等命令要求所有key必须在同一个slot中,如果不在同一个slot中返回该错误。
for redis cluster, eval/evalsha number of keys can't be negative or zero
eval和evalsha命令必须至少带一个key,numkeys参数大于0。
request refused, too many pending request
后端堆积了过多未处理完的request,新请求被拒绝。出现的原因是因为客户端使不合理的使用了pipeline。