二.安装haproxy
#wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.20.tar.gz
#uname -a
Linux ip1 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 i686 i386 GNU/Linux
#make TARGET=linux26 prefix=/usr/local/haproxy install
#cd /usr/local/haproxy
配置haproxy
#vim haproxy.conf
- global
- maxconn 5120
- chroot /usr/local/haproxy
- uid 100
- gid 100
- daemon
- quiet
- nbproc 2
- pidfile /usr/local/haproxy/haproxy.pid
- ########################################################
- defaults
- log global
- log 127.0.0.1 local3
- mode http
- option httplog
- option dontlognull
- option Redispatch
- retries 3
- maxconn 3000
- contimeout 5000
- clitimeout 50000
- srvtimeout 50000
- stats enable
- stats uri /admin
- stats auth admin:admin
- stats realm Haproxy \ statistic
- ##########################################################
- frontend www.gaoming.com
- bind *:80
- default_backend server_pool
- backend server_pool
- mode http
- balance roundrobin
- option forwardfor
- option httpclose
- option httpchk GET /index.html
- server web1 192.168.0.48:80 check inter 5000 fall 1 rise 2
- server web1 192.168.0.47:80 check inter 5000 fall 1 rise 2
启动haproxy
#/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.conf
域名解析到VIP上,用户访问VIP会负载到后端2台WEB上
测试高可用,关掉主haproxy,备用的会接管VIP
