Tuesday, June 19, 2012

How To install HAProxy Load Balancer on redhat


In my previous post i have described how to configure HAProxy load balancer on ubuntu. Here in this post i will describe how to do it on red-hat. Please make sure you are doing all this with necessary permissions for the your account.
01. Install HAProxy using following commands
wget http://haproxy.1wt.eu/download/1.2/src/haproxy-1.2.17.tar.gz
tar -zxf haproxy-1.2.17.tar.gz
cd haproxy-1.2.17
make
cp haproxy /usr/sbin/haproxy

02.Copy and edit config files
wget http://layer1.rack911.com/haproxy/haproxy-standard.cfg -O /etc/haproxy.cfg
wget http://layer1.rack911.com/haproxy/haproxy.init -O /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy

03.Starting server
 sudo  /etc/init.d/haproxy start

04.restarting server after any changes
 sudo  /etc/init.d/haproxy restart

Use the same config file mentioned in earlier post of mine. After installation everything is 
same as ubuntu.

Setup HAProxy Load Balancer on Ubuntu

01. installing haproxy on ubuntu machine
sudo apt-get install haproxy

02. Edit configurations file
sudo vi /etc/haproxy/haproxy.cfg

Add following text to file and save it

global
maxconn 4096
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout
5000
clitimeout
50000
srvtimeout
50000
listen webcluster *:80
mode http
stats enable
stats auth us3r:passw0rd
balance roundrobin
option httpchk HEAD / HTTP/1.0
option forwardfor
cookie LSW_WEB insert
option httpclose
server web01 10.100.2.85:8280 cookie LSW_WEB01 check
server web02 10.100.2.85:8281 cookie LSW_WEB02 check
03. Setting startup parameter for HAProxy set enabled as 1 to start HAproxy
sudo vi /etc/default/haproxy

# Set ENABLED to 1 if you want the init script to start haproxy.
ENABLED=1

04. Start HAProxy form command line
sudo /etc/init.d/haproxy start

05. Restart HAProxy after any configuration change form command line
sudo /etc/init.d/haproxy restart

06. Start 2 ESB servers (Set HTTP port as 8280 and 8281) and with default configurations

07. Access Web user interface from browser
Type following url in browser and provide stat credentials you provided in configurations file(haproxy.cfg)

http://10.100.2.85:80/haproxy?stats

You will see following User interface.




08. Access ESB from browser or send requests to following url
http://10.100.2.85:80/services/echo?wsdl


Following Diagram shows you how this laod balancer works.