ldirectord NAT负载均衡不适用于协商检查

时间:2013-04-11 10:16:34

标签: linux wget nat

我正在使用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的活动页面(以及卷曲和w3m)。我尝试从其他两台机器上运行它,这两台机器都来自不同的子网,它运行良好!我意识到负载均衡器盒有些不合适。

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

所以在我看来,ldirector不知何故阻止自己访问真实服务器上的活页面?这看起来很奇怪而且不合逻辑。那么我可以做错什么呢?

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

真实服务器都可以从负载均衡器(可ping)访问。我是否有ldirectord的配置问题?

如何在活动测试期间准确跟踪ldirectord的作用?

一般来说,有人可以提供一些亮点,或者给我一些可能出错的想法或者我可能做错的事。

提前致谢:)

1 个答案:

答案 0 :(得分:0)

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

干杯!