keepalived

Notes:

  • If several backup servers have the same priority, the backup server with the highest IP address value becomes the master server.

Prerequisites:

1sysctl net.ipv4.ip_forward=1                     ## Enable IP Forwarding.
2modprobe ip_vs; lsmod | grep ip_vs               ## ip_vs module is present/loaded.
3echo ip_vs >> /etc/modules-load.d/modules.conf   ## Ensure ip_vs module is loaded on boot.
4sysctl net.ipv4.ip_nonlocal_bind=1               ## If something else needs to bind to the VIP. (eg: HAProxy, Load Balancer, etc.)

Example config:

Show Sample Config

Example Track Script (curlLocalHost.sh):

#!/bin/bash
"/bin/curl localhost"