haproxy配置监控redis主备切换

环境前提:
    redis sentinel配置,三台主机,且配置运行良好
    

配置文件中添加:
frontend ft_redis
 bind 0.0.0.0:6379 name redis
 default_backend bk_redis

backend bk_redis
 option tcp-check
 tcp-check connect
 tcp-check send PING\r\n
 tcp-check expect string +PONG
 tcp-check send info\ replication\r\n
 tcp-check expect string role:master
 tcp-check send QUIT\r\n
 tcp-check expect string +OK
 server R1 10.118.36.10:6379 check inter 1s
 server R2 10.118.36.74:6379 check inter 1s
 server R3 10.118.5.161:6379 check inter 1s
haproxy配置监控redis主备切换_第1张图片
当结果如下所示,则表示成功,那么试着切换redis的master和slave吧

你可能感兴趣的:(redis,haproxy,集群,负载均衡)