HAProxy is a
free, very fast and reliable solution offering high
availability,load
balancing, and proxying for TCP and HTTP-based applications. It
is particularly suited for very high traffic web sites and powers
quite a number of the world’s most visited ones. See more
at http://haproxy.org
This tuturial,
I use hostname and ip as follows:
10.11.218.250
(haproxy)
10.11.218.251
(srv-web01)
10.11.218.252
(srv-web02)
Installing
HAProxy server
#yum install
haproxy [RedHat Systems]
#apt-get
install haproxy [Debian Systems]
Configuring
HAProxy Server
Opening the
main HAProxy configuration file ‘/etc/haproxy/haproxy.cfg’ and
editing the following content:
#----------------------------------------------------------------
# Global settings
global
# need to:
# to have these messages end up in /var/log/haproxy.log you will
#
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# 1) configure syslog to accept network log events. This is done
# /etc/sysconfig/syslog
#
# /etc/sysconfig/syslog
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
#
# local2.* /var/log/haproxy.log
#
# turn on stats unix socket
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
log global
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------
# Defaults settings
defaults
mode http
option redispatch
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
retries 3
timeout check 20
timeout http-request 20
timeout queue 86400
timeout connect 86400
timeout client 86400
timeout server 86400
timeout http-keep-alive 30
frontend lb_in
maxconn 50000
#----------------------------------------------------------------
#main frontend which proxys to the backends
bind *:80
default_backend lb_http
backend lb_http
balance roundrobin
mode http
server srv-web01 10.11.218.251:80 check
server srv-web02 10.11.218.252:80 check
#-------------------------- THE END -----------------------------
Restarting and
verify HAProxy Load Balancer
Comments
Post a Comment