共计 1802 个字符,预计需要花费 5 分钟才能阅读完成。
Keepalived VIP 切换的两种情况:
1.keepalived 进程被停止。
2.keepalived 中 track_script 检测失败。
haproxy 检测:
vrrp_script chk_haproxy {
script “killall -0 haproxy” # cheaper than pidof
interval 2 # check every 2 seconds
weight -2
}
切换相关日志:tail -f /var/log/messages
Keepalived_vrrp[32408]: VRRP_Script(chk_haproxy) failed
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Received higher prio advert
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Entering BACKUP STATE
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) removing protocol VIPs.
Keepalived_vrrp[32408]: VRRP_Script(chk_haproxy) succeeded
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) forcing a new MASTER election
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) forcing a new MASTER election
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Transition to MASTER STATE
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Entering MASTER STATE
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) setting protocol VIPs.
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 10.1.1.56
Keepalived_vrrp[32408]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 10.1.1.56
切换失败的情况:
keepalived 进程被停止时 VIP 可以正常切换,keepalived 进程运行状态下,haproxy 相关服务停止后,VIP 未如期进行切换。
分析:
停止 haproxy 服务,手动执行 killall -0 haproxy && echo “success” || echo “fail”,返回结果是 success。
停止 haproxy 服务后,ps aux |grep haproxy 发现还有一个正常启动的 haproxy,killall -9 haproxy 后发现 tail -f /var/log/messages 出现 VIP 正常切换的日志。
Linux 下 HAProxy+Keepalived 双机高可用方案 http://www.linuxidc.com/Linux/2016-02/128566.htm
Haproxy+Keepalived 搭建 Weblogic 高可用负载均衡集群 http://www.linuxidc.com/Linux/2013-09/89732.htm
Keepalived+HAProxy 配置高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/56748.htm
CentOS 6.3 下 Haproxy+Keepalived+Apache 配置笔记 http://www.linuxidc.com/Linux/2013-06/85598.htm
Haproxy + KeepAlived 实现 WEB 群集 on CentOS 6 http://www.linuxidc.com/Linux/2012-03/55672.htm
Haproxy+Keepalived 构建高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/55880.htm
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2016-03/129015.htm