To Gain Knowledge and to become a one, who all wants to become

Dreams are not those which are seen during sleep ,but Dreams are those which do not let you sleep,so see the dreams
and work hard to make them true.

Haproxy Load Balancer

Download the haproxy package and extract it
the cd haproxy-version
make install
cp the haproxy.cfg file from install-dir/examples/haproxy.cfg and edit it as below-

# this config needs haproxy-1.1.28 or haproxy-1.2.1

log local0 //For logging
log local1 notice
#log loghost local0 info
maxconn 4096
user haproxy
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
stats enable //This enables the statstics of haproxy server and you can view it in browser by http://ipaddress/haproxy-status
stats uri /haproxy-status
stats auth user:passwd

listen appli1-rewrite
cookie SERVERID rewrite
mode http
balance source
server app1_2 cookie app1inst2 check inter 2000 rise 2 fall 5
server app1_1 cookie app1inst1 check inter 2000 rise 2 fall 5

option httpchk

Configuring logging

Edit /etc/sysconfig/syslog


Edit /etc/syslog.conf. Add the following:

local0.* /var/log/haproxy.log

local1.* /var/log/haproxy-1.log

Restart Syslog

service syslog restart

Keep Alived Daemon

yum install keepalived
Keepalived Configuration File /etc/keepalived/keepalived.conf

vrrp_script chk_haproxy { # Requires keepalived-1.1.13
script "killall -0 haproxy" # cheaper than pidof
interval 0 # check every 2 seconds
weight 2 # add 2 points of prio if OK

vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 51
priority 101 # 101 on master, 100 on backup
virtual_ipaddress {
track_script {