Software to have a floating/ the same shared/ failover IP address.
sudo apt install keepalived
/etc/keepalived/keepalived.conf
# Global Settings for notifications
global_defs {
notification_email {
it@wieser-hv.de # Email address for notifications
}
notification_email_from id@domain.com # The from address for the notifications
smtp_server 192.168.20.64 # SMTP server address
smtp_connect_timeout 15
}
# Define the script used to check if haproxy is still working
vrrp_script chk_haproxy {
script "/usr/bin/killall -0 haproxy"
interval 2
weight 2
}
# Configuration for Virtual Interface
vrrp_instance LB_VIP {
interface eth0
state MASTER # set to BACKUP on the peer machine
priority 101 # set to 99 on the peer machine
virtual_router_id 51
smtp_alert # Enable Notifications Via Email
authentication {
auth_type AH
auth_pass myP@ssword! # Password for accessing vrrpd. Same on all devices
}
unicast_src_ip {{ip-master}} # Private IP address of master
unicast_peer {
{{ip-backup}} # Private IP address of the backup haproxy
}
# The virtual ip address shared between the two loadbalancers
virtual_ipaddress {
{{v-ip}}
}
# Use the Defined Script to Check whether to initiate a fail over
track_script {
chk_haproxy
}
}