Haproxy负载配置

 下载地址: http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.24.tar.gz

127.0.0.1# tar zxvf haproxy-1.3.15.7.tar.gz   
127.0.0.1# cd haproxy-1.3.15.7  
# 说明:linux下指定内核的版本
127.0.0.1# make TARGET=linux26 PREFIX=/usr/haproxy
127.0.0.1# make install PREFIX=/usr/haproxy
默认无配置文件新增
vi /usr/haproxy/conf/haproxy.cfg
global
      log 127.0.0.1 local0 notice
      maxconn 10240
      chroot /usr/haproxy
      uid 99
      gid 99
      nbproc 4
      daemon
      pidfile /usr/haproxy/haproxy.pid

defaults
      log global
      mode http
      option httplog
      option dontlognull
      option forwardfor
      option httpclose
      retries 3
      option redispatch

      maxconn 2000
      stats uri   /haproxy-admin
      contimeout 5000
      clitimeout  50000
      srvtimeout  50000

listen webcluster 0.0.0.0:80
      balance leastconn
      option httpchk HEAD /index.htm HTTP/1.0
      server web1 192.168.xx.xx:81 cookie 1 weight 5 check inter 2000 rise 2 fall 3
      server web2 192.168.xx.xx:82 cookie 2 weight 3 check inter 2000 rise 2 fall 3
 执行: /usr/haproxy/sbin/haproxy -f /usr/haproxy/conf/haproxy.cfg
 
验证状态:

猜你喜欢

转载自pluto418.iteye.com/blog/1905403