2017-01-05 9 views
1

I가 다음과 같은 시나리오 :HaProxy - 그룹의 TCP와 HTTP 호스트가 따라 서로

Haproxy 내 서버의 두 그룹의 앞에 실행 :

  • 이 HTTP 서버 (활성/백업)
  • 이 TCP 서버 (활성/백업) 지금 내려갑니다 (상기 HTTP 및 TCP 장애 활성 서비스 중 하나의 백업들에 활성 측면에서 장애 조치를 할

같은 시간).

HAproxy에서 그렇게 할 방법이 있습니까? 지금까지는 프로토콜에 따라 둘 중 하나만 장애 조치를 수행 할 수 있었지만 둘 다 할 수는 없었습니다. 이것들을 그룹화 할 수 있습니까? 가 fe_conn 지침

답변

2

같은 ACL 및 것들을 통해 수행 할 수 있는지 궁금

내가 haproxy의 nbsrv가 여기서 일하는 생각합니다. nbsrv 수, 정상 인스턴스 수가 둘 중 하나에서 원하는 양 이하로 떨어지면 둘 다 풀 백업 백엔드로 전환됩니다. 그렇지 않으면 기본 풀만 사용하십시오. 다음은 그 예 1.5.18에 대한 확인하지만 최신 버전에 잘 작동합니다 :

defaults all 
    timeout connect 30s 
    timeout client 30s 
    timeout server 30s 
    mode http 

# http frontend 
frontend http *:80 
    # use the backup service if EITHER service is down 
    acl use_backup nbsrv(http_service) lt 1 
    acl use_backup nbsrv(tcp_service) lt 1 
    use_backend http_service_backup if use_backup 
    default_backend http_service 

# tcp frontend 
frontend tcp_10000 *:10000 
    mode tcp 
    # use the backup service if EITHER service is down 
    acl use_backup nbsrv(http_service) lt 1 
    acl use_backup nbsrv(tcp_service) lt 1 
    use_backend tcp_service_backup if use_backup 
    default_backend tcp_service 

backend tcp_service 
    mode tcp 
    # main tcp instance here 
    # can also include backup server here with backup directive if desired 
    server tcp-service1 tcp-service1.local:10000 check 

backend tcp_service_backup 
    mode tcp 
    # backup tcp instance here 
    server tcp-service2 tcp-service2.local:10000 check 

backend http_service 
    # main http instance here 
    # can also include backup server here with backup directive if desired 
    server http-service1 http-service1.local:80 check 

backend http_service_backup 
    # backup http instance here 
    server http-service2 http-service2.local:80 check  

더 nbsrv 세부 사항은 https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#nbsrv를 참조하십시오.