2010年7月14日 星期三

Server Load Balance

HAProxy可以讓我們簡單架設一個Load Balance的機器。Debian架設方法如下:

# apt-get install haproxy

若要啟用,記得修改/etc/default/haproxy的設定檔
# vim /etc/default/haproxy
Enabled=1

接著便是依據實際環境對Load Balance的設定檔(/etc/haproxy/haproxy.cfg)做修改,可參考此網站

global
    maxconn 10000
    user    haproxy
    group   haproxy
    daemon
    nbproc  8
   
defaults
    log           global
    mode          http
    option        httplog
    option        dontlognull
    retries       3
    option        redispatch
    option        httpclose
    maxconn       32768
    contimeout    5000
    clitimeout    30000
    srvtimeout    30000
 

listen            web-server
    bind          0.0.0.0:80
    balance       roundrobin
    server        w1 192.168.1.1:80 weight 3 check
    server        w2 192.168.1.2:80 weight 3 check
    option        httpchk GET /index.html

    option        redispatch
    option        forwardfor

最後,啟動Service
# /etc/init.d/haproxy start

沒有留言:

張貼留言