有没有只将连接路由到一台服务器的 HAProxy 负载平衡算法?
Is there any HAProxy load balancing algorithm that routes connections to only one server?
我在它们前面有三台服务器(MariaDB 服务)和一台 HAProxy 服务器,HAProxy 使用 roundrobin 将连接分配到这些服务器。但我希望 HAProxy 服务器必须将所有连接路由到 server1。如果 server1 不可达,它必须路由到 server2.. 是否有任何负载均衡算法可以实现?
您正在寻找的可能是 failover/backup 配置,请在此处查看更多详细信息 (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 only
used in load balancing when all other non-backup servers are
unavailable. Requests coming with a persistence cookie referencing the
server will always be served though. By default, only the first
operational backup server is used, unless the "allbackups" option is
set 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
我在它们前面有三台服务器(MariaDB 服务)和一台 HAProxy 服务器,HAProxy 使用 roundrobin 将连接分配到这些服务器。但我希望 HAProxy 服务器必须将所有连接路由到 server1。如果 server1 不可达,它必须路由到 server2.. 是否有任何负载均衡算法可以实现?
您正在寻找的可能是 failover/backup 配置,请在此处查看更多详细信息 (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 only used in load balancing when all other non-backup servers are unavailable. Requests coming with a persistence cookie referencing the server will always be served though. By default, only the first operational backup server is used, unless the "allbackups" option is set 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