汤圆拌饺子 2021-09-27 10:25 采纳率: 50%
浏览 74

SpringBoot整合 Redis集群实现分布式session管理

连接redis中配置的节点:

spring:
  redis:
    cluster:
      nodes: 8.136.33.185:7000,8.136.33.185:7001,8.136.33.185:7002,8.136.33.185:7003,8.136.33.185:7004,8.136.33.185:700 ,8.136.33.185:7006,8.136.33.185:7007

报错:节点不存在,超时


2021-09-26 19:50:17.638  WARN 17696 --- [ioEventLoop-4-3] i.l.c.c.t.DefaultClusterTopologyRefresh  : Unable to connect to [172.19.27.236:7002]: connection timed out: /172.19.27.236:7002
2021-09-26 19:50:17.639  WARN 17696 --- [ioEventLoop-4-4] i.l.c.c.t.DefaultClusterTopologyRefresh  : Unable to connect to [172.19.27.236:7003]: connection timed out: /172.19.27.236:7003
2021-09-26 19:50:17.638  WARN 17696 --- [ioEventLoop-4-1] i.l.c.c.t.DefaultClusterTopologyRefresh  : Unable to connect to [172.19.27.236:7000]: connection timed out: /172.19.27.236:7000
2021-09-26 19:50:17.638  WARN 17696 --- [ioEventLoop-4-2] i.l.c.c.t.DefaultClusterTopologyRefresh  : Unable to connect to [172.19.27.236:7001]: connection timed out: /172.19.27.236:7001
2021-09-26 19:50:17.644  WARN 17696 --- [ioEventLoop-4-4] i.l.c.c.t.DefaultClusterTopologyRefresh  : Unable to connect to [172.19.27.236:7007]: connection timed out: /172.19.27.236:7007
2021-09-26 19:50:17.644  WARN 17696 --- [ioEventLoop-4-1] i.l.c.c.t.DefaultClusterTopologyRefresh  : Unable to connect to [172.19.27.236:7004]: connection timed out: /172.19.27.236:7004
2021-09-26 19:50:17.644  WARN 17696 --- [ioEventLoop-4-3] i.l.c.c.t.DefaultClusterTopologyRefresh  : Unable to connect to [172.19.27.236:7006]: connection timed out: /172.19.27.236:7006
2021-09-26 19:50:17.645  WARN 17696 --- [ioEventLoop-4-2] i.l.c.c.t.DefaultClusterTopologyRefresh  : Unable to connect to [172.19.27.236:7005]: connection timed out: /172.19.27.236:7005
2021-09-26 19:50:30.473  WARN 17696 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.data.redis.connection.ClusterCommandExecutionFailureException: Redis connection failed; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 172.19.27.236:7000; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Redis connection failed; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 172.19.27.236:7000
2021-09-26 19:50:30.481  WARN 17696 --- [           main] io.lettuce.core.RedisChannelHandler      : Connection is already closed
2021-09-26 19:50:30.482  WARN 17696 --- [           main] io.lettuce.core.RedisChannelHandler      : Connection is already closed
2021-09-26 19:50:30.483  WARN 17696 --- [           main] io.lettuce.core.RedisChannelHandler      : Connection is already closed
2021-09-26 19:50:30.607  WARN 17696 --- [           main] io.lettuce.core.RedisChannelHandler      : Connection is already closed

详细信息:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-09-26 19:50:30.688 ERROR 17696 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.data.redis.connection.ClusterCommandExecutionFailureException: Redis connection failed; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 172.19.27.236:7000; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Redis connection failed; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 172.19.27.236:7000
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.10.jar:5.3.10]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.10.jar:5.3.10]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.10.jar:5.3.10]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.10.jar:5.3.10]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.10.jar:5.3.10]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.10.jar:5.3.10]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.10.jar:5.3.10]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.10.jar:5.3.10]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.10.jar:5.3.10]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.10.jar:5.3.10]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.5.jar:2.5.5]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.5.jar:2.5.5]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.5.jar:2.5.5]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.5.jar:2.5.5]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.5.jar:2.5.5]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.5.jar:2.5.5]
    at com.bdqn.RedisSessionManagerApplication.main(RedisSessionManagerApplication.java:10) ~[classes/:na]
Caused by: org.springframework.data.redis.connection.ClusterCommandExecutionFailureException: Redis connection failed; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 172.19.27.236:7000; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Redis connection failed; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 172.19.27.236:7000
    at org.springframework.data.redis.connection.ClusterCommandExecutor.collectResults(ClusterCommandExecutor.java:267) ~[spring-data-redis-2.5.5.jar:2.5.5]
    at org.springframework.data.redis.connection.ClusterCommandExecutor.executeCommandAsyncOnNodes(ClusterCommandExecutor.java:210) ~[spring-data-redis-2.5.5.jar:2.5.5]
    at org.springframework.data.redis.connection.ClusterCommandExecutor.executeCommandOnAllNodes(ClusterCommandExecutor.java:178) ~[spring-data-redis-2.5.5.jar:2.5.5]
    at org.springframework.data.redis.connection.lettuce.LettuceClusterServerCommands.executeCommandOnAllNodes(LettuceClusterServerCommands.java:390) ~[spring-data-redis-2.5.5.jar:2.5.5]
    at org.springframework.data.redis.connection.lettuce.LettuceClusterServerCommands.getConfig(LettuceClusterServerCommands.java:240) ~[spring-data-redis-2.5.5.jar:2.5.5]
    at org.springframework.data.redis.connection.DefaultedRedisConnection.getConfig(DefaultedRedisConnection.java:1416) ~[spring-data-redis-2.5.5.jar:2.5.5]
    at org.springframework.session.data.redis.config.ConfigureNotifyKeyspaceEventsAction.getNotifyOptions(ConfigureNotifyKeyspaceEventsAction.java:76) ~[spring-session-data-redis-2.5.2.jar:2.5.2]
    at org.springframework.session.data.redis.config.ConfigureNotifyKeyspaceEventsAction.configure(ConfigureNotifyKeyspaceEventsAction.java:57) ~[spring-session-data-redis-2.5.2.jar:2.5.2]
    at org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration$EnableRedisKeyspaceNotificationsInitializer.afterPropertiesSet(RedisHttpSessionConfiguration.java:333) ~[spring-session-data-redis-2.5.2.jar:2.5.2]
    

error: Unable to connect to [172.19.27.236:7002]: connection timed out: /172.19.27.236:7002 【所有节点都不对】
是redis集群环境下会改变节点?

img

img

img

#已引入


        <!--springboot-redis-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <!--spring-data-redis session 管理-->
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-data-redis</artifactId>
        </dependency>

  • 写回答

2条回答 默认 最新

  • _Onelone丶 2021-09-27 10:33
    关注

    这个是局域网吧,你用本机能ping通?

    评论

报告相同问题?

问题事件

  • 创建了问题 9月27日

悬赏问题

  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题