I'm running 2 keepalived servers that share a common IP (Server1 and Server2). Server1 is the master, and whenever haproxy dies, Server2 should take over. If Server1 comes back up, Server2 should release the vIP and let Server1 take over again.
I've managed to get that running using the 2 configs below, however, I recently noticed that it stopped working.
The Servers are running CentOS 7 and is fully updated. If I manually kill keepalived on Server1, it fails over to Server2 and when keepalived comes back up, Server1 takes over again. However, if I kill haproxy, keepalived registers that the check_haproxy check failed, but doesn't failover.
Just to make sure it's not the FW or SELinux, I've removed all IPtables rules and disabled SELinux.
The configs are:
Server1
global_defs {
# Keepalived process identifier
# Probably should be unique: http://www.keepalived.org/LVS-NAT-Keepalived-HOWTO.html
lvs_id haproxy_DH
}
# Script used to check if HAProxy is running
vrrp_script check_haproxy {
script "killall -0 haproxy"
interval 2
weight 2
}
# Virtual interface
# The priority specifies the order in which the assigned interface to take over in a failover
vrrp_instance VI_01 {
state EQUAL
interface eno16777984
virtual_router_id 51
notify /etc/keepalived/notify.sh
priority 100
# The virtual ip address shared between the two loadbalancers
virtual_ipaddress {
10.9.17.20
10.9.17.19
}
track_script {
check_haproxy
}
}
Server2
global_defs {
# Keepalived process identifier
# Probably should be unique: http://www.keepalived.org/LVS-NAT-Keepalived-HOWTO.html
lvs_id haps2a
# Script used to check if HAProxy is running
vrrp_script check_haproxy {
script "killall -0 haproxy"
interval 2
weight 2
}
# Virtual interface
# The priority specifies the order in which the assigned interface to take over in a failover
vrrp_instance VI_01 {
state EQUAL
interface eno16777984
virtual_router_id 51
notify /etc/keepalived/notify.sh
priority 100
# The virtual ip address shared between the two loadbalancers
virtual_ipaddress {
10.9.17.20
10.9.17.19
}
track_script {
check_haproxy
}
}