Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Spring Redisson Sentinel Error - At least two sentinels are required

$
0
0

I am using Sentinel mode for Redis. I am using Redisson Client version 3.9.1

<dependencies><dependency><groupId>org.redisson</groupId><artifactId>redisson-spring-data-20</artifactId><version>${redisson-version}</version></dependency><dependency><groupId>org.redisson</groupId><artifactId>redisson</artifactId><version>${redisson-version}</version></dependency></dependencies>

The configuration of Sentinel using Redisson:

@EnableCachingpublic class RedisCache {    @Autowired    private ObjectMapper objectMapper;    @Bean    public RedissonClient redissonClient() {        Config config = new Config();        config.setCodec(new JsonJacksonCodec(objectMapper));        config.useSentinelServers()                    .setMasterName("redis-master")                    .addSentinelAddress("redis://localhost:26378")                    .addSentinelAddress("redis://localhost:26379");        return Redisson.create(config);    }    @Bean    public RedissonConnectionFactory redissonConnectionFactory(RedissonClient redisson) {        return new RedissonConnectionFactory(redisson);    }}

I am running two sentinel servers and one Redis master with no slave.This is just a setup on my local environment.
Output of some commands:

redis-cli -p 26379127.0.0.1:26379> SENTINEL get-master-addr-by-name redis-master1) "127.0.0.1"2) "6379"redis-cli -p 26378127.0.0.1:26378> SENTINEL get-master-addr-by-name redis-master1) "127.0.0.1"2) "6379"

Whenever I am running my Spring Boot Application, I get the following error:

       Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redissonClient' defined in class path resource [xxxx/cache/impl/redis/config/RedisCache.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.redisson.api.RedissonClient]: Factory method 'redissonClient' threw exception; nested exception is org.redisson.client.RedisConnectionException: At least two sentinels should be defined in Redis configuration!......            at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0 (AbstractBeanFactory.java:317)            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222)            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:315)            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:204)            at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType (ServletContextInitializerBeans.java:226)            at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType (ServletContextInitializerBeans.java:214)            at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans (ServletContextInitializerBeans.java:91)            at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init> (ServletContextInitializerBeans.java:80)            at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans (ServletWebServerApplicationContext.java:250)            at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize (ServletWebServerApplicationContext.java:237)            at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup (TomcatStarter.java:54)            at org.apache.catalina.core.StandardContext.startInternal (StandardContext.java:5245)            at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:150)            at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1420)            at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1410)            at java.util.concurrent.FutureTask.run (FutureTask.java:266)            at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)            at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)            at java.lang.Thread.run (Thread.java:748)        [INFO] ------------------------------------------------------------------------        [INFO] BUILD FAILURE        [INFO] ------------------------------------------------------------------------        [INFO] Total time: 22.566 s        [INFO] Finished at: 2018-12-07T13:44:14+05:30        [INFO] ------------------------------------------------------------------------        [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.1.RELEASE:run (default-cli) on project xxx: An exception occurred while running. null: InvocationTargetException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthEndpoint]: Factory method 'healthEndpoint' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.redis.RedisHealthIndicatorConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redissonConnectionFactory' defined in class path resource [xxxxxxx/cache/impl/redis/config/RedisCache.class]: Unsatisfied dependency expressed through method 'redissonConnectionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redissonClient' defined in class path resource [xxxxxx/cache/impl/redis/config/RedisCache.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.redisson.api.RedissonClient]: Factory method 'redissonClient' threw exception; nested exception is org.redisson.client.RedisConnectionException: At least two sentinels should be defined in Redis configuration!

How do I resolve this error?

PS: I have tried master-slave configuration also, with one sentinel attached to the host and other one attached to the slave, but the error remains the same. I have tried sentinels running on different local machines with different private IPs, but the error remains the same.Tried with 3 sentinel servers, no benefits.


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>