Keepalived VIP automatic failover
Keepalived:
1. The keepalived process is stopped.
2. track_script detection failed in keepalived.
Haproxy Detection:
Vrrp_script chk_haproxy {
Script "killall-0 haproxy" # cheaper than pidof
Interval 2 # check every 2 seconds
Weight-2
}
Switch related logs: tail-f/var/log/messages
Keepalived_vrrp [1, 32408]: VRRP_Script (chk_haproxy) failed
Keepalived_vrrp [32408]: VRRP_Instance (VI_1) initialized ed 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 [1, 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
Failed switchover:
When the keepalived process is stopped, the VIP can be switched normally. When the keepalived process is running and the haproxy service is stopped, the VIP fails to be switched as scheduled.
Analysis:
Stop the haproxy service and manually execute killall-0 haproxy & echo "success" | echo "fail". The returned result is success.
After the haproxy service is stopped, ps aux | grep haproxy finds a properly started haproxy. After killall-9 haproxy, logs of normal VIP switching in tail-f/var/log/messages are found.
HAProxy + Keepalived dual-host high availability solution in Linux
Haproxy + Keepalived build Weblogic high-availability server Load balancer Cluster
Keepalived + HAProxy configure high-availability Load Balancing
Haproxy + Keepalived + Apache configuration notes in CentOS 6.3
Haproxy + KeepAlived WEB Cluster on CentOS 6
Haproxy + Keepalived build high-availability Load Balancing
This article permanently updates the link address: