Setting up Keepalived for System-level HA

tested on slackware current (oct 2021) and debian12

THTTPD / HAPROXY / whatever runs on every node

for the second and third use-cases we need to identify the nodes

#sbopkg -i thttpd
wget https://lab.nethence.com/slackpkgs/2021-10/thttpd-2.29-x86_64-1_SBo.tgz
installpkg --terse thttpd-2.29-x86_64-1_SBo.tgz
echo '<p>hello this is node1' > /var/www/thttpd/index.html
echo '<p>hello this is node2' > /var/www/thttpd/index.html
echo '<p>hello this is node3' > /var/www/thttpd/index.html

we’re enabling the check script only and we should avoid being contra-productive here, the restriction needs to be as light as possible, as with pidof.

vrrp_script checkacme {
        script "/sbin/pidof thttpd"
        #weight 50
        interval 1
        fall 2
        rise 1
}

vrrp_instance ACME {
        state BACKUP
        interface xenbr0
        virtual_router_id 51
        priority 1
        advert_int 1
        virtual_ipaddress {
                10.0.0.209/24
        }
        track_script {
                checkacme
        }
    notify "/var/tmp/notify.bash"
}

Highly-available outbound MTA

see postfix-relay-ha

Ready to go

back to the main guide

Additional notes

we use the overall notify script only to check about the various states, and prefer to use specific notify_state definitions instead.

    vi /var/tmp/notify.bash

    #!/bin/bash

    echo `date` -- $HOSTNAME received $@ >> /var/tmp/keepalive.log

    chmod +x /var/tmp/notify.bash

Resources

check & notify

16.11 About Keepalived Notification and Tracking Scripts https://docs.oracle.com/cd/E37670_01/E41138/html/section_hxz_zdw_pr.html

Keepalived Check and Notify Scripts https://tobru.ch/keepalived-check-and-notify-scripts/

Keepalived check and notify scripts https://wenchma.github.io/2017/04/19/keepalived-check-and-notify-scripts.html

https://tobru.ch/keepalived-check-and-notify-scripts/ ==> check vs. notify

tcp check

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/load_balancer_administration/ch-initial-setup-vsa ==> TCP_CHECK

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/load_balancer_administration/s1-initial-setup-conf-dr-vsa ==> TCP_CHECK again

squid HA with check script

https://woshub.com/keepalived-high-availability-with-ip-failover/ ==> track_script

nginx HA with check script

https://www.digitalocean.com/community/tutorials/how-to-set-up-highly-available-web-servers-with-keepalived-and-reserved-ips-on-ubuntu-14-04 ==> system/service ha with check script

Nginx and Keepalived https://warlord0blog.wordpress.com/2018/05/15/nginx-and-keepalived/

https://docs.nginx.com/nginx/admin-guide/high-availability/ha-keepalived/ ==> that’s for nginx plus

Active-Passive HA for NGINX Plus on AWS Using Elastic IP Addresses https://docs.nginx.com/nginx/deployment-guides/amazon-web-services/high-availability-keepalived/

aws-ha-elastic-ip/nginx-ha-notify https://github.com/nginxinc/aws-ha-elastic-ip/blob/master/nginx-ha-notify

Split-brain split brain problem (Keepalived) https://titanwolf.org/Network/Articles/Article?AID=abc85391-3972-4f2f-8a1a-a4817b4174ea

How to set up Keepalived for High Availability and Load Balancing https://www.marksei.com/howto-keepalived-high-availability-load-balancing/


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun