페이지

2014년 4월 18일 금요일

[linux]how to install and config haproxy(load balance)


  • get the haproxy rpm
    • haproxy-1.4.22-3.el6.x86_64.rpm
  • set the configure file
# vi /etc/haproxy/haproxy.cfg 



#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------

frontend  nameOfPort1*:18001
    acl url_static       path_beg       -i /static /images /javascript /stylesheets
    acl url_static       path_end       -i .jpg .gif .png .css .js

    use_backend static          if url_static
    default_backend            nameOfPort1

frontend  nameOfPort1*:18002
    acl url_static       path_beg       -i /static /images /javascript /stylesheets
    acl url_static       path_end       -i .jpg .gif .png .css .js

    use_backend static          if url_static
    default_backend            nameOfPort2
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend nameOfPort1
    balance     roundrobin
    server  app1 123.456.789.123:25500 check
    server  app2 123.456.789.124:25500 check
    server  app3 123.456.789.125:25500 check

backend nameOfPort2
    balance     roundrobin
    server  app1 123.456.789.123:25501 check
    server  app2 123.456.789.123:25501 check
    server  app3 123.456.789.123:25501 check



  • if you want to see log file, set the rsyslog
# vi /etc/rsyslog.conf


# Provides UDP syslog reception
$ModLoad imudp
$UDPServerAddress 127.0.0.1
$UDPServerRun 514
SYSLOGD_OPTIONS="-m 0 -r"

local2.*                                                /var/log/haproxy.log


  • restart rsyslog and haproxy

# service rsyslog restart
# service haproxy restart

댓글 없음:

댓글 쓰기

image

image