1

I have configured a failover load balancer, so that it acts as a backup whenever my primary goes down. So I have setup Keepalived that switches the floating virtual IP address to the other machine whenever it is unable to find the service HAProxy running on other machine. The IP addresses mentioned in conf file are present on my eth1 interface.

On my primary load balancer I am getting

systemctl status keepalived

● keepalived.service - Keepalive Daemon (LVS and VRRP)
     Loaded: loaded (/lib/systemd/system/keepalived.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-05-15 18:06:32 UTC; 21min ago
   Main PID: 659 (keepalived)
      Tasks: 2 (limit: 1131)
     Memory: 4.7M
     CGroup: /system.slice/keepalived.service
             ├─659 /usr/sbin/keepalived --dont-fork
             └─711 /usr/sbin/keepalived --dont-fork

May 15 18:27:57 ubuntu-s-1vcpu-1gb-blr1-01 killall5[2250]: only one argument, a signal number, allowed
May 15 18:28:01 ubuntu-s-1vcpu-1gb-blr1-01 killall5[2252]: only one argument, a signal number, allowed
May 15 18:28:03 ubuntu-s-1vcpu-1gb-blr1-01 killall5[2253]: only one argument, a signal number, allowed
May 15 18:28:05 ubuntu-s-1vcpu-1gb-blr1-01 killall5[2256]: only one argument, a signal number, allowed
May 15 18:28:07 ubuntu-s-1vcpu-1gb-blr1-01 killall5[2259]: only one argument, a signal number, allowed
May 15 18:28:09 ubuntu-s-1vcpu-1gb-blr1-01 killall5[2260]: only one argument, a signal number, allowed
May 15 18:28:11 ubuntu-s-1vcpu-1gb-blr1-01 killall5[2261]: only one argument, a signal number, allowed
May 15 18:28:13 ubuntu-s-1vcpu-1gb-blr1-01 killall5[2262]: only one argument, a signal number, allowed
May 15 18:28:15 ubuntu-s-1vcpu-1gb-blr1-01 killall5[2263]: only one argument, a signal number, allowed
May 15 18:28:17 ubuntu-s-1vcpu-1gb-blr1-01 killall5[2264]: only one argument, a signal number, allowed

sudo nano /etc/keepalived/keepalived.conf

vrrp_script chk_haproxy {
    script "pidof haproxy"
    interval 2
}

vrrp_instance VI_1 {
    interface eth1
    state MASTER
    priority 200


virtual_router_id 33
    unicast_src_ip 10.122.0.2
    unicast_peer {
        10.122.0.3
    }


authentication {
        auth_type PASS
        auth_pass password
}

    track_script {
        chk_haproxy
    }

    notify_master /etc/keepalived/master.sh

}

On my secondary load balancer

systemctl status keepalived

● keepalived.service - Keepalive Daemon (LVS and VRRP)
     Loaded: loaded (/lib/systemd/system/keepalived.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-05-15 17:57:16 UTC; 36min ago
   Main PID: 329993 (keepalived)
      Tasks: 2 (limit: 4677)
     Memory: 1.9M
     CGroup: /system.slice/keepalived.service
             ├─329993 /usr/sbin/keepalived --dont-fork
             └─330005 /usr/sbin/keepalived --dont-fork

May 15 17:57:16 ubuntu-s-2vcpu-4gb-blr1-01 Keepalived_vrrp[330005]: Script `chk_haproxy` now returning 1
May 15 17:57:16 ubuntu-s-2vcpu-4gb-blr1-01 Keepalived_vrrp[330005]: VRRP_Script(chk_haproxy) failed (exited with status 1)
May 15 17:57:16 ubuntu-s-2vcpu-4gb-blr1-01 Keepalived_vrrp[330005]: (VI_1) Entering FAULT STATE
May 15 18:05:21 ubuntu-s-2vcpu-4gb-blr1-01 killall5[330439]: only one argument, a signal number, allowed
May 15 18:10:13 ubuntu-s-2vcpu-4gb-blr1-01 killall5[330679]: only one argument, a signal number, allowed
May 15 18:11:37 ubuntu-s-2vcpu-4gb-blr1-01 killall5[330750]: only one argument, a signal number, allowed
May 15 18:17:53 ubuntu-s-2vcpu-4gb-blr1-01 killall5[331070]: only one argument, a signal number, allowed
May 15 18:24:21 ubuntu-s-2vcpu-4gb-blr1-01 killall5[331386]: only one argument, a signal number, allowed
May 15 18:28:11 ubuntu-s-2vcpu-4gb-blr1-01 killall5[331552]: only one argument, a signal number, allowed
May 15 18:30:31 ubuntu-s-2vcpu-4gb-blr1-01 killall5[331649]: only one argument, a signal number, allowed

sudo nano /etc/keepalived/keepalived.conf

vrrp_script chk_haproxy {
    script "pidof haproxy"
    interval 2
}

vrrp_instance VI_1 {
    interface eth1
    state BACKUP
    priority 100


virtual_router_id 33
    unicast_src_ip 10.122.0.3
    unicast_peer {
        10.122.0.2
    }


authentication {
        auth_type PASS
        auth_pass password
    }

    track_script {
        chk_haproxy
    }

    notify_master /etc/keepalived/master.sh
}

Output of pidof pidof haproxy

Primary

root@ubuntu-s-1vcpu-1gb-blr1-01:~# pidof haproxy
726 719

Secondary

root@ubuntu-s-2vcpu-4gb-blr1-01:~# pidof haproxy
328842 328841

Note : I ran the /etc/keepalived/master.sh script manually and it was working successfully.

EDIT1: It does not work even when I use pidof -s haproxy

Himanshuman
  • 113
  • 7

1 Answers1

0

Reinstalling the KeepAlived package fixed my issue.

To remove keepalived :

sudo apt-get remove -y keepalived
sudo apt-get remove --auto-remove -y keepalived

Installing KEEPALIVED

sudo apt-get update
sudo apt-get install -y keepalived
Himanshuman
  • 113
  • 7