Jan*_*ard 17 scaling load-balancing haproxy
我们希望能够按需添加更多后端服务器。现在我没有看到一种方法可以在不重新启动 haproxy 的情况下将更多后端服务器添加到配置文件中。
Kyl*_*ndt 16
我还没有测试过这个特定的用例,但 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)
Run Code Online (Sandbox Code Playgroud)
如果您有一个 init 脚本来启动和停止 haproxy,它可能会reload
通过如下函数支持该参数:
haproxy_reload()
{
$HAPROXY -f "$CONFIG" -p $PIDFILE -D $EXTRAOPTS -sf $(cat $PIDFILE) \
|| return 2
return 0
}
Run Code Online (Sandbox Code Playgroud)
从手册:
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)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7787 次 |
最近记录: |