아파치에 mod_proxy_balancer를 적용할 때 failover 처리는 어떻게 하나요?

조회수 7223회

안녕하세요. 현재 제가 구성중인 서버의 구조는 아래 그림과 같습니다: 이미지

그리고 apache0의 httpd.conf 파일은 아래와 같습니다:

# 생략

ProxyRequests off
ProxyPreserveHost on

<Proxy *>
    AddDefaultCharset off
    Order deny,allow
    Allow from all
</Proxy>

ProxyVia On

<VirtualHost *:80>
    ServerName mydomain.com

    Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
    <Proxy "balancer://focluster">
        BalancerMember http://mydomain.com:1081/ route=1
        BalancerMember http://mydomain.com:1082/ route=2
        ProxySet stickysession=ROUTEID
    </Proxy>
    ProxyPass "/" "balancer://focluster/"
</VirtualHost>

보시다시피 apache0에서 apache1과 apache2에 대한 proxy 기능을 수행하되 mod_proxy_balancer를 이용해 로드밸런싱을 적용한 상태입니다.

그리고 session 유지를 위해서 'ROUTEID'라는 쿠키에 stickysession 옵션을 걸어두었습니다.

이 상태에서 apache2가 죽었거나 apache2와 연결된 WAS가 죽었을 때 클라이언트의 요청을 apache1로 보내도록 하려면 어떻게 해야하나요?

1 답변

  • 좋아요

    1

    싫어요
    채택 취소하기

    로드밸런싱과 다른 이슈라서 원하는대로 안될것 같습니다. 질문한 내용은 HA와 관련된 설정이라서 별도의 방법이 필요하지 않나 싶네요. 참고: HAProxy

    그래도 Balancer만 가지고 한다면, 위 설정에서 다음과 같이 변경하여 테스트 해보세요.

    <Proxy "balancer://focluster">
        BalancerMember http://mydomain.com:1081/ route=1 status=-SE timeout=5 retry=60
        BalancerMember http://mydomain.com:1082/ route=2 status=-SE timeout=5 retry=60
        ProxySet stickysession=ROUTEID lbmethod=bybusyness failontimeout=on
    </Proxy>
    

    timeout=5는 연결제한시간을 둔 것입니다. 이 시간 동안 기다렸다가 실패하면 다시 / 로 요청합니다.

    Connection timeout in seconds. The number of seconds Apache httpd waits for data sent by / to the backend.

    failontimeout=on이 설정되면, 요청 한후 I/O의 읽기 타임아웃이 발생하면, 해당 워커를 에러상태로 강제로 셋팅합니다.

    If set, an IO read timeout after a request is sent to the backend will force the worker into error state. Worker recovery behaves the same as other worker errors. Available in Apache HTTP Server 2.4.5 and later.

    retry=60은 에러가 발생한 후 60초 후에 정상상태로 되돌려 다시 요청을 받을 수 있게 합니다.

    Connection pool worker retry timeout in seconds. If the connection pool worker to the backend server is in the error state, Apache httpd will not forward any requests to that server until the timeout expires. This enables to shut down the backend server for maintenance and bring it back online later. A value of 0 means always retry workers in an error state with no timeout.

    참조: https://httpd.apache.org/docs/current/mod/mod_proxy.html#balancermember

    • 답변 고맙습니다. 많은 도움이 되었어요! 편집요청빌런 2016.5.19 10:22

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)