consul实现redis-sentinelHA高可用-02
redis-sentinel哨兵模式部署
https://blog.51cto.com/9025736/2498152
consul集群部署参考文章
https://blog.51cto.com/9025736/2500976
规划
配置redis-sentinel自动切换主节点配置(仅需要consul_client节点配置)
[ consul.d]# cat redis-6379.json { "services": [ { "id": "redisnode1", "name": "redis", "tags": [ "master" ], "address": "192.168.31.178", "port": 6379, "checks": [ { "args": ["/usr/bin/bash","/data/a.sh"], "interval": "5s" } ] }, { "id": "redisnode2", "name": "redis", "tags": [ "master" ], "address": "192.168.31.179", "port": 6379, "checks": [ { "args": ["/usr/bin/bash","/data/b.sh"], "interval": "5s" } ] }, { "id": "redisnode3", "name": "redis", "tags": [ "master" ], "address": "192.168.31.180", "port": 6379, "checks": [ { "args": ["/usr/bin/bash","/data/c.sh"], "interval": "5s" } ] } ] } consul reload
注意:在consul json配置文件中,每个consul agent的service里面 id都不能重复,name是强制要求的,必须要有,如果id省略,则跟name来匹配,其他的都是可选的,可有可无。但为了能够使用某条服务信息,就必须要有IP和port,当然port可以在应用中指定。check最好要有,否则当出现问题时不能从consul中注销。
可以访问http://192.168.31.178/v1/catalog/service/redis来查看服务
dig检查
redis测试consul是否可以切换
停止192.168.31.178 redis-server
停止192.168.31.180 redis-server 开启 192.168.31.178 redis-server
相关推荐
anloan 2020-08-18
oLeiShen 2020-06-25
hyxinyu 2020-06-10
javashixisheng 2020-06-05
ajuan 2020-06-04
wishli 2020-05-19
JustHaveTry 2020-05-08
zhaolisha 2020-05-03
kong000dao0 2020-04-25
andylanzhiyong 2020-03-20
糊一笑 2020-03-07
furongwei 2020-03-03
凯哥Java 2020-02-03
xsg 2020-01-10
工作中的点点滴滴 2020-01-07
杨友山 2020-01-03
zhangll00 2019-12-31
Caleb0 2019-12-27
fengwuxichen 2019-12-27