I'm trying to create HA for HAProxy using keepalived on CentOS 8, here's what I have:
Virtual IP: 10.10.10.14
HAProxy Server 1: 10.10.10.15
HAProxy Server 2: 10.10.10.18
and my keepalived configuration on MASTER:
vrrp_script chk_haproxy {
script "killall -0 haproxy" # check the haproxy process
interval 2 # every 2 seconds
weight 2 # add 2 points if OK
}
vrrp_instance VI_1 {
interface ens190
state MASTER
virtual_router_id 51
priority 101
virtual_ipaddress {
10.10.10.14
}
track_script {
chk_haproxy
}
}
Keepalived config on BACKUP:
vrrp_script chk_haproxy {
script "killall -0 haproxy" # check the haproxy process
interval 2 # every 2 seconds
weight 2 # add 2 points if OK
}
vrrp_instance VI_1 {
interface ens165
state BACKUP
virtual_router_id 51
priority 100
virtual_ipaddress {
10.10.10.14
}
track_script {
chk_haproxy
}
}
But every time I try to stop my HAProxy process it won't connect to the backup server. Instead it only works on the server with the recent start of keepalived.
My ip -a command would return like this for Master:
inet 10.10.10.15/24 brd 10.10.10.255 scope global noprefixroute ens190
inet 10.10.10.14/32 scope global ens190
For Backup:
inet 10.10.10.18/24 brd 10.10.10.255 scope global noprefixroute ens165
inet 10.10.10.14/32 scope global ens165
Anything wrong? I have also set net.ipv4.ip_nonlocal_bind = 1 on my sysctl configuration. My logs only show the start and stop of the service?