VIP - 192.168.0.151


1번 서버 - 192.168.0.152

2번 서버 - 192.168.0.153


wget http://www.haproxy.org/download/1.5/src/haproxy-1.5.17.tar.gz

tar xvzf haproxy-1.5.17.tar.gz



uname -r


yum install wget gcc gcc-c++ autoconf automake make openssl openssl-devel pcre-devel zlib


make TARGET=linux2628 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1

make install


cp examples/haproxy.init /etc/init.d/haproxy

cp examples/examples.cfg /etc/haproxy/haproxy.cfg


chmod 755 /etc/init.d/haproxy



service haproxy start (or /etc/init.d/haproxy start)




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


# id

# 101 ~ 200 = HTTP

# 201 ~ 300 = TCP

# 501 ~ 600 = TEST



frontend searchWas

        bind 192.168.0.151:80

        option  httplog

        default_backend searchWas


backend searchWas

        id      101

        stats   enable

        stats   hide-version

        balance roundrobin

        # For Sticky Session

        appsession JSESSIONID len 30 timeout 3h request-learn prefix

        option  httplog

        option  httpchk GET /info.jsp

        option  http-server-close

        option  forwardfor

server search01 192.168.0.101:8080 check inter 2000 fastinter 500 downinter 5000 rise 3 fall 1

server search02 192.168.0.102:8080 check inter 2000 fastinter 500 downinter 5000 rise 3 fall 1


listen aqmp_real 192.168.0.151:5672

        id              201

        mode            tcp

        balance         roundrobin

        timeout client  3h

        timeout server  3h

        option          clitcpka

        server mq11 192.168.0.101:5672 check inter 5s rise 2 fall 3

        server mq21 192.168.0.101:5672 check inter 5s rise 2 fall 3


listen stats 0.0.0.0:40000       #Listen on all IP's on port 9000

    mode http

    balance

    timeout client 5000

    timeout connect 4000

    timeout server 30000


    #This is the virtual URL to access the stats page

    stats uri /haproxy_stats


    #Authentication realm. This can be set to anything. Escape space characters with a backslash.

    stats realm HAProxy\ Statistics


    #The user/pass you want to use. Change this password!

    #stats auth admin:admin


    #This allows you to take down and bring up back end servers.

    #This will produce an error on older versions of HAProxy.

    stats admin if TRUE


yum install keepalived



service rsyslog restart

service keepalived restart

service haproxy restart










[/etc/rsyslog.d/haproxy.conf]

local2.*    /var/log/haproxy.log





1번 서버 [/etc/keepalived/keepalived.conf]

! Configuration File for keepalived

global_defs {

        router_id HAProxy1

}


vrrp_script haproxy {

        script "killall -0 haproxy"

        interval 2

        weight 2

}



vrrp_instance VI_1 {

        debug 2

        virtual_router_id 50

        advert_int 1

        priority 101

        state MASTER

        interface eth0

        virtual_ipaddress {

                192.168.0.151 dev eth0

        }


        track_script {

                haproxy

        }


        notify_master "/etc/keepalived/master.sh"

        notify_backup "/etc/keepalived/backup.sh"

}


2번 서버 [/etc/keepalived/keepalived.conf]

! Configuration File for keepalived


global_defs {

        router_id HAProxy2

}


vrrp_script haproxy {

        script "killall -0 haproxy"

        interval 2

        weight 2

}



vrrp_instance VI_1 {

        debug 2

        virtual_router_id 50

        advert_int 1

        priority 100

        state BACKUP

        interface eth0

        virtual_ipaddress {

                192.168.0.151 dev eth0

        }


        track_script {

                haproxy

        }

}




[/etc/rsyslog.conf]


----------------------------


$ModLoad imudp

$UDPServerRun 514


----------------------------




[/etc/sysctl.conf]


----------------------------


# For keepalived - vrrp

net.ipv4.ip_nonlocal_bind=1


----------------------------





yum install rubygems

gem update

gem update --system


gem install haproxyctl


haproxyctl "enable server wasSearch/search01"

haproxyctl "disable server wasSearch/search01"


curl -d "s=search01&action=maint&b=#101" http://192.168.0.151:8080/haproxy_stats

curl -d "s=search01&action=ready&b=#101" http://192.168.0.151:8080/haproxy_stats


[참조] http://bryan.wiki/243

[참조] https://www.percona.com/blog/2014/10/03/haproxy-give-me-some-logs-on-centos-6-5/

+ Recent posts