【问题标题】:HAProxy multiple frontend/listenersHAProxy 多个前端/侦听器
【发布时间】:2018-07-19 22:50:21
【问题描述】:
我想使用一个 HAProxy 主机将流量从多个前端/侦听器 IP 引导到各自的后端。
有什么方法可以在 Debian/Centos 主机上轻松完成此任务?
不使用 dcoker 或其他任何东西,只是安装 haproxy 以将 tcp 连接卸载到多个其他服务器。
我读过的所有信息要么将我定向到 ACL,这将是极端的,因为我们有数千个域分布在许多“后端”服务器上,或者在“*”上显示侦听器,当然这是任意的。
我们之前使用的是 cisco 交换机负载平衡,现在希望在 VM 中完成这项工作,通过对各种服务器的请求进行易于消化的监控,并根据需要添加和删除资源。
HAProxy 启动正常,并且在 netstat -pln 中显示了我们在负载均衡器中配置的每个 IP 上的服务。
【问题讨论】:
标签:
web-services
load-balancing
web-hosting
haproxy
high-availability
【解决方案1】:
解决方案非常简单:
在基于 debian 的系统上:
配置您的 /etc/network/interfaces 文件以使用虚拟网络接口,例如:
# The primary or physical network interface
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8 8.8.4.4
# first virtual interface
auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
address 192.168.0.11
netmask 255.255.255.0
# second virtual interface
auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static
address 192.168.0.12
netmask 255.255.255.0