wxyfj 发表于 2015-11-20 10:45:25

haproxy的安装和基本设置

  haproxy的安装和基本设置
  首页
http://haproxy.1wt.eu/
  中文资料
http://cn.haproxy.org/download/1.3/doc/configuration-cn.txt
  参考WIKI
http://blog.iyunv.com/cenwenchu79/archive/2009/08/04/4409343.aspx
  一、haproxy的安装
下载得到文件
解开压缩
执行
  mkdir –p /usr/local/haproxy/logs/
  
make TARGET=linux26PREFIX=/usr/local/haproxy
  . make install PREFIX=/usr/local/haproxy
  

  # install -d /usr/local/sbin
# install haproxy /usr/local/sbin
# install -d /usr/local/share/man/man1
# install -m 644 doc/haproxy.1 /usr/local/share/man/man1
# install -d /usr/local/doc/haproxy
# for x in configuration architecture haproxy-en haproxy-fr; do \
>               install -m 644 doc/$x.txt /usr/local/doc/haproxy ; \
>         done
#
  
  检查安装结果:
  

  # haproxy
HA-Proxy version 1.4.20 2012/03/10
Copyright 2000-2012 Willy Tarreau <w@1wt.eu>
  Usage : haproxy [-f <cfgfile>]* [ -vdVD ] [ -n <maxconn> ] [ -N <maxpconn> ]
      [ -p <pidfile> ] [ -m <max megs> ]
      -v displays version ; -vv shows known build options.
      -d enters debug mode ; -db only disables background mode.
      -V enters verbose mode (disables quiet mode)
      -D goes daemon
      -q quiet mode : don't display messages
      -c check mode : only check config files and exit
      -n sets the maximum total # of connections (2000)
      -m limits the usable amount of memory (in MB)
      -N sets the default, per-proxy maximum # of connections (2000)
      -p writes pids of all children to this file
      -de disables epoll() usage even when available
      -ds disables speculative epoll() usage even when available
      -dp disables poll() usage even when available
      -sf/-st * finishes/terminates old pids. Must be last arguments.
  
  证明安装已经成功
  二、haproxy
vi haproxy.cfg
文件内容如下:
  global
      log 127.0.0.1   local0
      maxconn 4096
      chroot /usr/local/haproxy
      uid 99
      gid 99
      daemon
      nbproc 1
      pidfile /usr/local/haproxy/logs/haproxy.pid
      debug
      #quiet
  defaults
      log   127.0.0.1       local3
      mode    http
      option httplog
      option httpclose
      option dontlognull
      option forwardfor
      option redispatch
      retries 2
      maxconn 2000
      balance roundrobin
      stats   uri   /haproxy-stats
      contimeout      5000
      clitimeout      50000
      srvtimeout      50000
  listen web_proxy 0.0.0.0:80
      option httpchk GET /demo/ping.jsp
  server s1 127.0.0.1:8080 weight 3 check
      server s2 127.0.0.1:8081 weight 3 check
  启动命令
haproxy -f haproxy.cfg
报错:
# haproxy -f haproxy.cfg
236/112258 (5538) : Cannot create pidfile /usr/local/haproxy/logs/haproxy.pid
mkdir /usr/local/haproxy/logs 就可以了
  访问:
http://192.168.95.129:80/haproxy-stats
  调试启动命令:
haproxy -f haproxy.cfg -d
  
页: [1]
查看完整版本: haproxy的安装和基本设置