SpringCloud或者SpringBoot连接Redis哨兵模式集群,启动会报 Cannot retrieve initial cluster partitions from initial URIs 错误。现在整理Redis连接配置如下所示
redis:
timeout: 5000
lettuce:
pool:
max-idle: 8
min-idle: 1
max-wait: -1
max-active: 50
cluster:
max-redirects: 10
nodes: 172.16.17.123:6379,172.16.17.124:6380,172.16.17.125:6381,172.16.17.126:6382
password: redis@sentinel
database: 0
sentinel:
master: mymaster
nodes: 172.16.17.123:26379,172.16.17.124:26380,172.16.17.125:26381,172.16.17.126:26382
如果是哨兵模式,必须添加sentinel属性才可以,不然就会报错。