haproxy的配置安裝

hotdog04發表於2015-06-09

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
haproxy的配置安裝

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20625855/viewspace-1693421/,如需轉載,請註明出處,否則將追究法律責任。

相關文章