1、搭建参考
    https://github.com/1621740748/redis-sentinel/blob/master/README.md

    2、spring boot redis 哨兵模式 使用

    配置文件

    1. spring:
    2. redis:
    3. # host: 127.0.0.1
    4. # port: 6379
    5. password: mypassword
    6. database: 0 # Redis数据库索引(默认为0)
    7. timeout: 2000ms # 连接超时时间(毫秒)默认是2000ms
    8. lettuce:
    9. pool:
    10. max-active: 200 # 连接池最大连接数(使用负值表示没有限制)
    11. max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
    12. max-idle: 100 # 连接池中的最大空闲连接
    13. min-idle: 50 # 连接池中的最小空闲连接
    14. shutdown-timeout: 100ms
    15. sentinel: # 哨兵模式
    16. master: mymaster
    17. nodes: 10.10.0.27:26379,10.10.0.27:26380,10.10.0.27:26381

    maven配置

    1. <dependency>
    2. <groupId>org.springframework.boot</groupId>
    3. <artifactId>spring-boot-starter-data-redis</artifactId>
    4. </dependency>
    5. <dependency>
    6. <groupId>org.apache.commons</groupId>
    7. <artifactId>commons-pool2</artifactId>
    8. </dependency>