SpringBoot2 + redisson + sentinel

2.3.7.RELEASE

1.引入依赖


            org.redisson
            redisson-spring-boot-starter
            3.13.6
 

2.yml配置

spring:
  redis:
    redisson:
      file: classpath:redisson.yml

3.redisson.yml 编写

sentinelServersConfig:
  idleConnectionTimeout: 10000
  connectTimeout: 10000
  timeout: 3000
  retryAttempts: 3
  retryInterval: 1500
  failedSlaveReconnectionInterval: 3000
  failedSlaveCheckInterval: 60000
  password: 123456
  subscriptionsPerConnection: 5
  clientName: null
  loadBalancer: ! {}
  subscriptionConnectionMinimumIdleSize: 1
  subscriptionConnectionPoolSize: 50
  slaveConnectionMinimumIdleSize: 24
  slaveConnectionPoolSize: 64
  masterConnectionMinimumIdleSize: 24
  masterConnectionPoolSize: 64
  readMode: "SLAVE"
  subscriptionMode: "SLAVE"
  sentinelAddresses:
    - "redis://10.254.203.116:26379"
    - "redis://10.254.203.116:26380"
    - "redis://10.254.203.116:26381"
  masterName: "mymaster"
  database: 0
threads: 16
nettyThreads: 32
codec: ! {}
transportMode: "NIO"

参考:https://github.com/redisson/redisson/wiki/2.-Configuration#272-sentinel-yaml-config-format

最好不要复制中文版的 Sentinel YAML config format,有可能会出现意想不到的错误

4.使用

@Autowired
private RedissonClient redissonClient;
@Autowired
private StringRedisTemplate redisTemplate;

直接注入就可以愉快的玩耍了

你可能感兴趣的:(JAVAEE,redisson,SpringBoot2,sentinel)