备忘录
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
-
timeout:连接超时时间(毫秒)
-
max-idle:连接池中的最大空闲连接数
-
min-idle:连接池中的最小空闲连接数
-
max-wait:连接池最大阻塞等待时间(使用负值表示没有限制)
-
max-active:连接池最大连接数(使用负值表示没有限制)
如果是哨兵模式,必须添加sentinel属性才可以,不然就会报错。