haproxy를 다시 시작하지 않고 haproxy에 더 많은 백엔드 서버를 추가하는 방법이 있습니까?


17

필요에 따라 더 많은 백엔드 서버를 추가 할 수 있기를 원합니다. 현재 haproxy를 다시 시작하지 않고 구성 파일에 더 많은 백엔드 서버를 추가하는 방법이 없습니다.

답변:


15

이 특정 사용 사례를 테스트하지는 않았지만 haproxy는 "핫 리로드"를 지원합니다.

2.4.1) Hot reconfiguration
--------------------------
The '-st' and '-sf' command line options are used to inform previously running
processes that a configuration is being reloaded. They will receive the SIGTTOU
signal to ask them to temporarily stop listening to the ports so that the new
process can grab them. If anything wrong happens, the new process will send
them a SIGTTIN to tell them to re-listen to the ports and continue their normal
work. Otherwise, it will either ask them to finish (-sf) their work then softly
exit, or immediately terminate (-st), breaking existing sessions. A typical use
of this allows a configuration reload without service interruption :

 # haproxy -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)

haproxy를 시작하고 중지하는 init 스크립트가 있으면 다음 reload과 같은 함수를 사용 하여 인수를 지원할 수 있습니다.

haproxy_reload()
{
    $HAPROXY -f "$CONFIG" -p $PIDFILE -D $EXTRAOPTS -sf $(cat $PIDFILE) \
        || return 2
    return 0
}

1
나는 이것을 시도했지만 내 카운터를 지우는 것을 발견했습니다. 아마도 내가 잘못한 일을하고 있습니까? 아니면 예상되는 행동입니까?
Leandro López

6

매뉴얼에서 :

> 1.6) 프로세스 관리 지원

Haproxy는 이제 pidfile 개념을 지원합니다. '-p'명령 행 인수 또는 'pidfile'전역 옵션 뒤에 파일 이름이 있으면이 파일이 제거 된 다음 모든 하위의 pid로 채워집니다 (한 줄에 하나씩) (데몬 모드에서만). 이 파일은 chroot 내에 없으므로 읽기 전용 chroot로 작업 할 수 있습니다. 프로세스를 시작하는 사용자가 소유하며 0644 권한을 갖습니다.

예 :

global
    daemon
    quiet
    nbproc  2
    pidfile /var/run/haproxy-private.pid

# to stop only those processes among others :
# kill $(</var/run/haproxy-private.pid)

# to reload a new configuration with minimal service impact and without
# breaking existing sessions :
# haproxy -f haproxy.cfg -p /var/run/haproxy-private.pid -sf $(</var/run/haproxy-private.pid)

1

또한 HA 프록시 버전에 따라이 페이지의 haproxy.com에 설명 된대로 HA 프록시 동적 API를 고려할 수 있습니다. https://www.haproxy.com/blog/dynamic-scaling-for-microservices-with -런타임 -api /

HA-Proxy Dynamic API는 Enterprise 버전과 함께 제공됩니다.

일반적인 관행으로 서버를 즉시 추가 / 제거하거나 프로젝트가 이러한 사용 사례를 암시하는 경우 HA-Proxy Dynamic API를 고려해야합니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.