Skip to content

Instantly share code, notes, and snippets.

@alastair
Created April 22, 2015 09:48
Show Gist options
  • Save alastair/a5a680e4692c01542ccf to your computer and use it in GitHub Desktop.
Save alastair/a5a680e4692c01542ccf to your computer and use it in GitHub Desktop.
keepalive configuration
# Define the script used to check if haproxy is still working
vrrp_script chk_haproxy {
script "killall -0 haproxy"
interval 2
weight 2
}
# Define the script used to check if nginx is still working
vrrp_script chk_nginx {
script "killall -0 nginx"
interval 2
weight 2
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 101
advert_int 1
# uncomment to send emails on state changes
# smtp_alert # Activate SMTP notifications
authentication {
auth_type PASS
auth_pass put_a_password_here
}
virtual_ipaddress {
11.11.11.11/24
}
# Use the script above to check if we should fail over
track_script {
chk_haproxy
chk_nginx
}
}
}
vrrp_script chk_haproxy { # Requires keepalived-1.1.13
script "killall -0 haproxy" # widely used idiom
interval 2 # check every 2 seconds
weight 2 # add 2 points of prio if OK
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 100
advert_int 1
# uncomment to send emails on state changes
# smtp_alert # Activate SMTP notifications
authentication {
auth_type PASS
auth_pass put_a_password_here
}
virtual_ipaddress {
11.11.11.11/24
}
track_script {
chk_haproxy
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment