简体   繁体   English

为什么我的 spring 启动应用程序无法访问哨兵提供的 redis 节点的服务,但 redis 节点实际上是健康的

[英]Why my spring boot app couldn't access service of the redis node provided by sentinel but that redis node is actually healthy

Platform: Windows 10 JDK: 11 Command to start redis and sentinel:平台:Windows 10 JDK:11 命令启动 redis 和哨兵:

cd PATH_TO_REDIS\redis_s6379
redis-server.exe redis.windows.conf
redis-server.exe sentinel.conf --sentinel

Redis client: jedis Redis 客户:jedis

Detailed log 详细日志

partial log部分日志

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.micrometer.spring.web.servlet.WebMvcMetricsFilter]: Factory method 'webMetricsFilter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'endpointHandlerMapping' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping]: Factory method 'endpointHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcEndpoints' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthMvcEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.class]: Unsatisfied dependency expressed through method 'healthMvcEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration$$EnhancerBySpringCGLIB$$700f4ba6]: Constructor threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$RedisHealthIndicatorConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jedisConnectionFactory' defined in class path resource [com/corp_name/corp_config/RedisConfig.class]: Invocation of init method failed; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: All sentinels down, cannot determine where is mymaster master is running...

The solution for this one is to make sure your sentinel.conf file have the right config.这个解决方案是确保您的 sentinel.conf 文件具有正确的配置。

Add 127.0.0.1 redis-server in your host file.在您的主机文件中添加 127.0.0.1 redis-server。 Use "redis-server" for both the configurations of file("redis.windows.conf") and file("sentinel.conf").文件(“redis.windows.conf”)和文件(“sentinel.conf”)的配置都使用“redis-server”。

The above solution is inferred from reading the source code file of Connection.java.上述方案是通过阅读Connection.java的源码文件推断出来的。

redis/clients/jedis/Connection.java:184 redis/clients/jedis/Connection.java:184

Some prerequisite:一些先决条件:

  • windows doesn't support ping the host itself using ipv4 address but mac does. windows 不支持使用 ipv4 地址 ping 主机本身,但 mac 可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM