jxp2002 发表于 2019-1-2 06:35:09

正式环境haproxy配置

  安装 HAProxy 配置负载均衡
  

  HAProxy 可以完成较复杂的负载均衡工作,同时还可对服务器健康检测,有 down 机的自动停止分发,当服务器正常后,又自动均衡到刚死过的服务器。
  

  下载:haProxy 1.3.15 http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.15.7.tar.gz
  

  安装:
  

  

  1.cd /home
  

  2.wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.15.7.tar.gz
  

  3.tar -zxvf haproxy-1.3.15.7.tar.gz
  

  4.cd haproxy-1.3.15.7
  

  5.mkdir –p /usr/local/haproxy/logs/
  

  6.make TARGET=linux26 PREFIX=/usr/local/haproxy
  

  7.make install PREFIX=/usr/local/haproxy
  

  8.cd /usr/local/haproxy
  

  9.vi haproxy.cfg
  

  创建/修改配置haproxy.cfg
linux-241:/usr/local/haproxy # cat haproxy.cfg
global
chroot /usr/local/haproxy # more secure
daemon
nbproc 1
group nobody
user nobody
log 127.0.0.1 local0 info # syslog
pidfile /usr/local/haproxy/logs/haproxy.pid
ulimit-n 65536
spread-checks 5m # percent of randomness in the check interval
stats timeout 5m
stats maxconn 100
defaults
log global
mode tcp
retries 3
option redispatch
option abortonclose
maxconn 32000
contimeout 5m
clitimeout 5m
timeout check 5m
timeout client 5m
timeout connect 5m
timeout server 5m
listen python1 0.0.0.0:8008
mode tcp
balance roundrobin
server one1   119.147.19.43:80weight 1 maxconn 10000 check inter 10s
# server one2   10.142.8.52:8070weight 1 maxconn 10000 check inter 10s
listen stats :8045
mode http
stats refresh 30s
stats uri /haproxy_stats
stats realm 13qz\proxy
stats auth admin:admin  




页: [1]
查看完整版本: 正式环境haproxy配置