tar xzvf haproxy-1.5.8.tar.gz
cd haproxy-1.5.8
make TARGET=linux26 PREFIX=/usr/local/haproxy
make install PREFIX=/usr/local/haproxy
cp examples/haproxy.cfg /usr/local/haproxy/

配置文件
cat haproxy.cfg
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 40960
chroot /usr/share/haproxy
uid 99
gid 99
daemon
nbproc 1
#debug
#quiet
pidfile /usr/local/haproxy/haproxy.pid
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
option forwardfor
maxconn 40960
timeout connect 360ms
timeout client 360ms
timeout server 360ms
stats uri /status
stats auth admin:Admin

frontend www-in
bind 192.168.1.21:80
default_backend webs

backend webs
mode http
balance roundrobin
option forwardfor
option httpchk HEAD /index.html
server web01 192.168.1.202:80 check
server web02 192.168.1.203:80 check
server web03 192.168.1.204:80 check
server web04 192.168.1.205:80 check

启动
/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg

关闭
killall haproxy

重启
/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg -p /usr/local/haproxy/haproxy.pid -sf `cat /usr/local/haproxy/haproxy.pid`

发表评论

电子邮件地址不会被公开。 必填项已用*标注