Friday, April 15, 2011

Ha-Proxy Load Balancer

I had tested with centos 5.5 64bit

Down load latest haproxy

http://haproxy.1wt.eu/download/1.3/src/

useradd haproxy

Install it with

make TARGET=linux26

sysctl file entry

net.ipv4.ip_nonlocal_bind = 1

vi /etc/haproxy.cfg

global

log 127.0.0.1 local0

log 127.0.0.1 local3

maxconn 4096

user haproxy

group haproxy

defaults

log global

maxconn 2000

contimeout 5000

clitimeout 30000

srvtimeout 30000

listen tomcat_server VirtualIP:8080

mode tcp

stats enable

balance roundrobin

option tcplog

server webA Realserver1 weight 10 maxconn 300 check

server webB Realserver2 weight 10 maxconn 300 check

option abortonclose

listen mail_server VirtualIP:25

mode tcp

stats enable

balance roundrobin

option smtpchk EHLO localhost

option tcplog

server mailA ServerIP1 weight 10 maxconn 300 check

server mailB ServerIP2 weight 10 maxconn 300 check

server mailC ServerIP3 weight 10 maxconn 300 check

server mailD ServerIP4 weight 10 maxconn 300 check

server mailF ServerIP5 weight 10 maxconn 300 check

option abortonclose

listen web_appl 0.0.0.0:81

mode http

stats enable

balance roundrobin

server web1 127.0.0.1:80 weight 10 maxconn 100 check

enabeling logs

/etc/sysconfig/syslog:

SYSLOGD_OPTIONS=”-m 0 -r”

http://linuxadminzone.com/enable-or-fix-logging-for-haproxy-load-balancer/


/etc/syslog.conf: please check documentation for logs

local0.* /var/log/haproxy.log

service syslog restart

Now Start haproxy service.

No comments: