问题解决:io.lettuce.core.RedisCommandExecutionException: CLUSTERDOWN

问题场景

程序调用redis集群,总是间歇性地提示报错,报错提示如下:

org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: CLUSTERDOWN The cluster is down
        at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:54)
        at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:52)
        at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41)
        at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44)
        at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42)
        at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:268)
        at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.convertLettuceAccessException(LettuceStringCommands.java:799)
        at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.set(LettuceStringCommands.java:180)
        at org.springframework.data.redis.connection.DefaultedRedisConnection.set(DefaultedRedisConnection.java:281)
        at org.springframework.data.redis.connection.DefaultStringRedisConnection.set(DefaultStringRedisConnection.java:955)
        at org.springframework.data.redis.core.DefaultValueOperations.lambda$setIfAbsent$11(DefaultValueOperations.java:310)
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:224)
        at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184)
        at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:95)
        at org.springframework.data.redis.core.DefaultValueOperations.setIfAbsent(DefaultValueOperations.java:310)

本篇博文主要是讲述问题发生的原因及解决方案。

问题环境

软件 版本
redis 5

问题原因

通过查看日志,发现有从节点的同步存在问题,报错提示如下:

207636:S 04 Mar 2021 21:31:19.986 * Connecting to MASTER test:6379
207636:S 04 Mar 2021 21:31:19.986 * MASTER <-> REPLICA sync started
207636:S 04 Mar 2021 21:31:19.986 * Non blocking connect for SYNC fired the event.
207636:S 04 Mar 2021 21:31:19.986 * Master replied to PING, replication can continue...
207636:S 04 Mar 2021 21:31:19.986 * (Non critical) Master does not understand REPLCONF listening-port: -NOAUTH Authentication required.
207636:S 04 Mar 2021 21:31:19.986 * (Non critical) Master does not understand REPLCONF capa: -NOAUTH Authentication required.
207636:S 04 Mar 2021 21:31:19.986 * Partial resynchronization not possible (no cached master)
207636:S 04 Mar 2021 21:31:19.987 # Unexpected reply to PSYNC from master: -NOAUTH Authentication required.
207636:S 04 Mar 2021 21:31:19.987 * Retrying with SYNC...
207636:S 04 Mar 2021 21:31:19.987 # MASTER aborted replication with an error: NOAUTH Authentication required.

查看关键字:NOAUTH Authentication required。是因为配置了密码保护,但是配置没有弄好,导致主从节点同步数据存在问题。

解决方案

在配置文件里面加上以下配置:

masterauth ${设置的密码}

然后重新启动redis集群。

结果

异常消失,问题得到解决。

总结

配置之间存在关联,需要多检查。

随缘求赞

如果我的文章对大家产生了帮忙,可以在文章底部点个赞或者收藏;
如果有好的讨论,可以留言;
如果想继续查看我以后的文章,可以点击关注
可以扫描以下二维码,关注我的公众号:枫夜之求索阁,查看我最新的分享!
在这里插入图片描述
拜拜

扫描二维码关注公众号,回复: 12790295 查看本文章

猜你喜欢

转载自blog.csdn.net/u013084266/article/details/114380192