標籤:
一.環境介紹
1.Centos6
2. haproxy-1.4.25.tar.gz
二.安裝
$ curl -O http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.25.tar.gz$ tar zxvf haproxy-1.4.25.tar.gz$ cd haproxy-1.4.25$ make TARGET=linux26 PREFIX=/usr/local/haproxy$ make install PREFIX=/usr/local/haproxy$ cp examples/haproxy.cfg /usr/local/haproxy/$ cp examples/haproxy.init /etc/init.d/haproxy$ chmod 755 /etc/init.d/haproxy$ ln -s /usr/local/haproxy /etc/$ ln -s /usr/local/haproxy/sbin/haproxy /usr/sbin/$ groupadd haproxy$ useradd -g haproxy haproxy -s /sbin/nologin -M$ grep haproxy /etc/passwdhaproxy:x:507:507::/home/haproxy:/sbin/nologin
三.配置
$ vi /etc/haproxy/haproxy.cfgglobal log 127.0.0.1 local0 log 127.0.0.1 local1 notice #log loghost local0 info maxconn 40960 chroot /usr/local/haproxy uid 803 gid 803 daemon nbproc 1 #debug #quietdefaults log global mode http option httplog option dontlognull option forwardfor option httpclose retries 3 option redispatch maxconn 2000 timeout connect 500000 timeout client 5000000 timeout server 50000000frontend http-in bind 192.168.233.2:80 mode http option httplog log global acl is_a hdr_beg(host) -i www.test.com acl is_a hdr_beg(host) -i test.com use_backend a_server if is_a stats enable stats hide-version stats uri /admin-status stats auth admin:admin123 stats admin if TRUE backend a_server balance roundrobin cookie SESSION_COOKIE insert indirect nocache option httpchk HEAD /Default.aspx HTTP/1.0 fullconn 10000 server web58 192.168.233.158:80 minconn 100 maxconn 1000 cookie web1 weight 6 check inter 2000 rise 2 fall 4 server web85 192.168.233.185:80 minconn 100 maxconn 1000 cookie web2 weight 6 check inter 2000 rise 2 fall 4
四.啟動
/etc/init.d/haproxy start
Centos 編譯安裝Haproxy