2, 190上安装haproxy
# wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.20.tar.gz
# tar zcvf haproxy-1.3.20.tar.gz
# cd haproxy-1.3.20
# make TARGET=linux26 PREFIX=/usr/local/haproxy #将haproxy安装到/usr/local/haproxy
# make install PREFIX=/usr/local/haproxy
修改/root/haproxy-1.3.15.10/example/haproxy.cfg文件
global log 127.0.0.1 local3 maxconn 20480 chroot /usr/local/haproxy uid 1004 #1004为haproxy 用户的uid ,haproxy用户需要自己手动创建 gid 1004 daemon quiet nbproc 1 pidfile /var/run/haproxy.pid defaults log global mode http maxconn 20480 option httplog option httpclose option forwardfor option dontlognull option redispatch retries 3 balance roundrobin contimeout 5000 clitimeout 50000 srvtimeout 50000 listen web_poll 192.168.0.190:8081 mode http option httplog option dontlognull option logasap option forwardfor option httpclose # option httpchk GET /index.html 配置负载服务器访问信息 server web1 192.168.0.191:80 cookie 1 check inter 2000 rise 3 fall 3 server web2 192.168.0.192:80 cookie 1 check inter 2000 rise 3 fall 3 server web3 192.168.0.190:80 cookie 1 check inter 2000 rise 3 fall 3 #配置haproxy的状态监控页面 listen status 192.168.0.190:8080 stats enable stats uri /stats stats auth admin:123456 stats realm (Haproxy\ statistic)
开启:/usr/local/sbin/haproxy –f /root/haproxy-1.3.15.10/example/haproxy.cfg
关闭:killall haproxy
注意需要将防火墙关闭:chkconfig iptables off或者chkconfig iptables stop