hueel 发表于 2015-12-24 11:06:27

haproxy的配置安装

  1、下载haproxy:
  http://www.haproxy.org/
  
  2、指定目录安装
  mkdir -p /usr/local/haproxy
  tar -xvf  haproxy-1.4.tar.gz
  make TARGET=linux26 PREFIX=/usr/local/haproxy   #系统内核版本2.6
  make install PREFIX=/usr/local/haproxy
  3、调整配置文件:
  (192.168.1.32:20001-192.168.1.35:20001是node节点)
  cat  /etc/haproxy.cfg
  global
  # log 127.0.0.1 local3 debug
  maxconn 20480
  chroot /usr/local/haproxy
  uid 0 
  gid 0
  daemon
  quiet
  nbproc 4     #提升性能关键参数
  pidfile /var/run/haproxy.pid
  spread-checks 2
  ulimit-n 82000
  defaults
  log global
  timeout server  3s
  timeout connect 3s
  timeout client 30s
  timeout http-request 3s
  timeout queue 3s
  mode tcp
  balance static-rr
  # balance roundrobin
  #  balance source
  maxconn 10000
  listen redis_cluster *:60001
  mode tcp
  balance  static-rr
  maxconn  10000
  option httplog
  option dontlognull
  option logasap
  option forwardfor
  option httpclose
  #        option redis-check
  server tm1 192.168.1.32:20001 weight 1  maxconn 10000 check inter 1s rise 2 fall 1
  server tm2 192.168.1.33:20001 weight 1  maxconn 10000 check inter 1s rise 2 fall 1
  server tm3 192.168.1.34:20001 weight 1  maxconn 10000 check inter 1s rise 2 fall 1
  server tm4 192.168.1.35:20001 weight 1 maxconn  10000 check inter 1s rise 2 fall 1
  
  listen  admin_status
  mode  http
  bind *:8083
  option httplog
  log global
  stats enable
  stats refresh 10s
  #        stats hide-version
  stats realm Haproxy Statistics
  stats uri  /status
  stats auth  zhaogp:1234
  stats admin if TRUE
  4、启动:
  haproxy  -D -f /etc/haproxy.cfg  -p /var/run/haproxy.pid
  5、监控:
  查看状态:http://localhost:8083/status
  用户密码:zhaogp/1234
页: [1]
查看完整版本: haproxy的配置安装