Setup HA load balancer with Haproxy and Keepalived on Ubuntu server 14.04

How to setup high availability on Ubuntu 14.04 for load balancers running haproxy

Install keepalived on both load balancer

sudo apt-get install keepalived

Create keepalived configuration on both load balancer.

sudo nano /etc/keepalived/keepalived.conf

Change the priority number for Master to be higher (keepalived no longer preempt)

vrrp_script chk_haproxy {
script "killall -0 haproxy"
interval 2
weight 2
}

vrrp_instance VI_1 {
interface eth0 #change it if yours is on another one.
state BACKUP #MASTER or BACKUP
virtual_router_id 5X #must be the same on all server nodes
priority 100 #Higher for MASTER. Keep same for nopreempt to work
nopreempt #Keep priority same for nopreempt to work

authentication {
auth_type PASS
auth_pass #place secure password here.
}
virtual_ipaddress {
192.168.1.XX #Put your virtual floating IP
}
track_script {
chk_haproxy
}
}

Start your keepalived service on both server.

sudo service keepalived start

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top