SpringBoot集成Redis Sentinel模式,报错:RedisCommandExecutionException: ERR unknown command `SENTINEL`

一、前提

SpringBoot项目集成Redis Sentinel模式,报错:

  • application.yml配置
# 哨兵模式
spring:
  redis:
    password: 12**56
    sentinel:
      master: mymaster
      nodes: *.*.*.196:6379,*.*.*.197:6380,*.*.*.198:6381

二、错误信息

2022-07-20 17:45:40.861 ERROR 33392 --- [nio-8081-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisException: java.util.concurrent.ExecutionException: io.lettuce.core.RedisCommandExecutionException: ERR unknown command `SENTINEL`, with args beginning with: `get-master-addr-by-name`, `mymaster`, ] with root cause

io.lettuce.core.RedisCommandExecutionException: ERR unknown command `SENTINEL`, with args beginning with: `get-master-addr-by-name`, `mymaster`, 
	at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:118) ~[lettuce-core-5.0.5.RELEASE.jar:na]

关键报错信息:
RedisCommandExecutionException
ERR unknown command 'SENTINEL'
with args beginning with: 'get-master-addr-by-name', 'mymaster', ]

三、原因

yml配置文件中,sentinel模式下,nodes的配置是哨兵的配置,不是redis的配置。所有,应该更正为哨兵IP:哨兵port
正确配置:

# 哨兵模式
spring:
  redis:
    password: 12**56
    sentinel:
      master: mymaster
      nodes: *.*.*.196:26379,*.*.*.197:26380,*.*.*.198:26381
# 26379,26380,26381:为哨兵对应的端口
posted @   zlonger  阅读(6107)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
点击右上角即可分享
微信分享提示