gpt4 book ai didi

ubuntu - 是否有任何 HAProxy 负载平衡算法仅将连接路由到一台服务器?

转载 作者:行者123 更新时间:2023-12-04 18:59:57 25 4
gpt4 key购买 nike

我在它们前面有三台服务器(MariaDB 服务)和一台 HAProxy 服务器,HAProxy 使用循环分配与这些服务器的连接。但我希望 HAProxy 服务器必须将所有连接路由到 server1。如果 server1 不可达,它必须路由到 server2 .. 是否有任何负载平衡算法使它成为可能?

最佳答案

您可能正在寻找故障转移/备份配置,请在此处查看更多详细信息 (https://www.haproxy.com/blog/failover-and-worst-case-management-with-haproxy/),这是一个基本示例:

backend mysql
mode tcp
balance leastconn
server s1 10.0.0.1:3306 check
server s2 10.0.0.2:3306 check backup
server s3 10.0.0.3:3306 check backup
来自 HAProxy docs :

backup

When "backup" is present on a server line, the server is onlyused in load balancing when all other non-backup servers areunavailable. Requests coming with a persistence cookie referencing theserver will always be served though. By default, only the firstoperational backup server is used, unless the "allbackups" option isset in the backend. See also the "no-backup" and "allbackups" options.


如果您的服务器属于 galera 集群,您可以尝试 httpwsrep :
backend mysql
mode tcp
option httpchk
default-server check port 9200
server s1 10.0.0.1:3306
server s2 10.0.0.2:3306
server s3 10.0.0.3:3306

关于ubuntu - 是否有任何 HAProxy 负载平衡算法仅将连接路由到一台服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62829054/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com