변군이글루

[리눅스] CentOS HA-Proxy 설정 및 테스트 본문

서___리눅스

[리눅스] CentOS HA-Proxy 설정 및 테스트

변군 변군이글루 2017.12.01 17:38

 

CentOS HA-Proxy 설정 및 테스트

 

1. haproxy 설치(HA-Proxy 1.5.18)

# yum install haproxy

 

2. haproxy conf 설정

vi /etc/haproxy/haproxy.cfg

global

log         127.0.0.1 local2

 

    chroot      /var/lib/haproxy

    pidfile     /var/run/haproxy.pid

    maxconn     4000

    user        haproxy

    group       haproxy

    daemon

 

    # turn on stats unix socket

    stats socket /var/lib/haproxy/stats

 

#---------------------------------------------------------------------

# common defaults that all the 'listen' and 'backend' sections will

# use if not designated in their block

#---------------------------------------------------------------------

defaults

    mode                    http

    log                     global

    option                  httplog

    option                  dontlognull

    option http-server-close

    option forwardfor       except 127.0.0.0/8

    option                  redispatch

    retries                 3

    timeout http-request    10s

    timeout queue           1m

    timeout connect         10s

    timeout client          1m

    timeout server          1m

    timeout http-keep-alive 10s

    timeout check           10s

    maxconn                 3000

 

#---------------------------------------------------------------------

# HTTP Site Configuration

#---------------------------------------------------------------------

listen http_apache 192.168.56.100:80

        mode http

        balance roundrobin

        option httpchk

        cookie SERVERID rewrite

        cookie JSESSIONID prefix

        option forwardfor

        server ac02 192.168.56.112:80 cookie ac02 check inter 2000 rise 2 fall 5

        server ac03 192.168.56.113:80 cookie ac03 check inter 2000 rise 2 fall 5

 

#---------------------------------------------------------------------

# HTTPS Site Configuration

#---------------------------------------------------------------------

listen https_apache 192.168.56.100:443

        mode tcp

        balance source

        server ac02 192.168.56.112:443 weight 1 maxconn 512 check

        server ac03 192.168.56.113:443 weight 1 maxconn 512 check

 

#---------------------------------------------------------------------

# round robin balancing between the various backends

#---------------------------------------------------------------------

listen stats :1936

    mode http

    stats enable

    stats hide-version

    stats refresh 30s

    stats show-node

    stats auth admin:password

    #stats uri /haproxy?stats

    stats realm Haproxy\ Statistics

    stats uri /

 

3. haproxy 서버 기동

# service haproxy restart

 

4. HAProxy Statistics Report 페이지

http://192.168.56.111:1936/

admin / password

 

 

참고URL:

https://www.upcloud.com/support/haproxy-load-balancer-centos/

https://tecadmin.net/install-and-configure-haproxy-on-centos/

 

 

0 Comments
댓글쓰기 폼