Springboot redisson 配置redis cluster
添加依赖
Maven
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.15.1</version>
</dependency>
Gradle
compile 'org.redisson:redisson-spring-boot-starter:3.15.1'
配置application.yaml
spring:
redis:
cluster:
nodes: 192.168.9.1:6379 192.168.9.2:6379 192.168.9.3:6379 192.168.9.1:6380 192.168.9.2:6380 192.168.9.3:6380
## 连接超时时间(毫秒)
timeout: 5000
lettuce:
pool:
max-active: 8
# 连接池阻塞等待时间(负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 8
# 连接池中最小空闲连接
min-idle:
# Redisson settings
#path to config - redisson.yaml
redisson:
file: classpath:redisson.yaml
config: | clusterServersConfig: idleConnectionTimeout: 10000 connectTimeout: 10000 timeout: 3000 retryAttempts: 3 retryInterval: 1500 failedSlaveReconnectionInterval: 3000 failedSlaveCheckInterval: 60000 password: null subscriptionsPerConnection: 5 clientName: null loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {} subscriptionConnectionMinimumIdleSize: 1 subscriptionConnectionPoolSize: 50 slaveConnectionMinimumIdleSize: 24 slaveConnectionPoolSize: 64 masterConnectionMinimumIdleSize: 24 masterConnectionPoolSize: 64 readMode: "SLAVE" subscriptionMode: "SLAVE" nodeAddresses: - "redis://192.168.9.1:6379" - "redis://192.168.9.2:6379" - "redis://192.168.9.3:6379" - "redis://192.168.9.1:6380" - "redis://192.168.9.2:6380" - "redis://192.168.9.3:6380" scanInterval: 1000 pingConnectionInterval: 0 keepAlive: false tcpNoDelay: false threads: 16 nettyThreads: 32 codec: !<org.redisson.codec.MarshallingCodec> {} transportMode: "NIO"
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/100324.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...