0

我正在使用 ldirectord 来平衡两个 HTTP 服务器。在负载均衡器框中,我具有以下网络配置:

eth0 用于内部目的,根本不参与负载平衡。在 eth1 上,我为机器配置了公共 IP(用于来自其他内部网络的访问)和负载均衡器的 VIP。eth2 用于访问真实服务器,这些服务器位于不同的子网中,只能通过同一子网中的 IP 访问。

详细情况如下:

# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
inet 127.0.0.2/8 brd 127.255.255.255 scope host secondary lo
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 00:50:56:a5:77:ae brd ff:ff:ff:ff:ff:ff
inet 192.168.8.216/22 brd 192.168.11.255 scope global eth0
inet6 fe80::250:56ff:fea5:77ae/64 scope link
   valid_lft forever preferred_lft forever

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 00:50:56:a5:77:af brd ff:ff:ff:ff:ff:ff
inet 172.22.9.100/22 brd 172.22.11.255 scope global eth1:1
inet 172.22.8.213/22 brd 172.22.11.255 scope global secondary eth1
inet6 fe80::250:56ff:fea5:77af/64 scope link
   valid_lft forever preferred_lft forever

4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
link/ether 00:50:56:a5:77:b0 brd ff:ff:ff:ff:ff:ff
inet 172.22.1.130/24 brd 172.22.1.255 scope global eth2
inet6 fe80::250:56ff:fea5:77b0/64 scope link
   valid_lft forever preferred_lft forever

这是我的 NAT 负载均衡的配置:

# cat /etc/ha.d/ldirectord.cf
autoreload = yes
quiescent = yes
checkinterval = 10
negotiatetimeout = 10
checktimeout = 5
emailalert = "Konstantin.Boyanov@bmf.bund.de"
emailalertfreq = 60
failurecount = 3


virtual = 172.22.9.100:80
    checktimeout = 10
    checktype = negotiate
    failurecount = 2
    negotiatetimeout = 10
    protocol = tcp
    quiescent = yes
    real = 172.22.1.133:80 masq 1024
    real = 172.22.1.134:80 masq 1024
    request = "alive.htm"
    receive = "I am alive"
    scheduler = wrr
    service = http
    persistent = 5

我还有两个额外的 iptables 规则来使 NATing 按预期工作:

# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
SNAT       all  --  anywhere             anywhere            to:172.22.9.100
SNAT       all  --  anywhere             anywhere            to:172.22.1.130

现在,问题是,活动检查没有按预期工作。虽然服务器在线(我可以 ping 它们和所有服务器),但 ldirector 并没有看到它并将它们标记为关闭。

如果我使用 ping 检查一切正常,但我们需要协商以进行更全面的服务检查(服务器 cna 可 ping,但 http 不工作等)。

我试图从负载平衡器框上的命令行下载alive.htm 页面,但失败了。

# wget http://172.22.1.133/alive.htm
--2013-04-11 09:52:44--  http://172.22.1.133/alive.htm
Connecting to 172.22.1.133:80... failed: Connection timed out.
Retrying.

首先,我认为问题出在 iptables 规则上。我删除了它们,但仍然无法使用 wget 下载活动页面(以及 curl 和 w3m )。我尝试从其他两台机器上获取它,它们都来自不同的子网,而且效果很好!我意识到负载平衡器盒有些问题。

然后我关闭了 ldirectord 并再次尝试了 wget。这次奏效了。

所以在我看来,ldirector 以某种方式阻止自己访问真实服务器上的活动页面?这看起来很奇怪而且不合逻辑。那么我做错了什么?

这些问题不是由 iptables 规则引起的,因为当我删除它们时,alive.htm 页面仍然不可用。

真实服务器都可以从负载平衡器访问(可ping通)。我有一些 ldirectord 的配置问题吗?

如何准确跟踪 ldirectord 在活动测试期间所做的事情?

一般来说,有人可以阐明或给我一些想法,什么可能是错的或我可能做错了什么。

提前致谢 :)

4

1 回答 1

0

我在负载均衡器上禁用了 IPv6,现在一切正常。我猜 LVS + IPv6 是俄罗斯轮盘赌 :)

干杯!

于 2013-04-11T14:57:38.010 回答