有没有办法添加更多的后端服务器haproxy而不重新启动haproxy?

我们希望能够按需添加更多的后端服务器。 现在我没有看到一种方法来添加更多的后端服务器到configuration文件,而无需重新启动haproxy

    我没有testing过这个特定的用例,但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它可能支持reload参数与一个函数,如:

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

    从手册:

    > 1.6)帮助进程pipe理

    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)