我使用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页面仍然不可用。
真正的服务器都可以从负载均衡器访问(可pingable)。我有一些ldirectord的配置问题吗?
如何准确地跟踪ldirectord在活动测试期间所做的工作?
一般来说,谁能给我一些启发,或者给我一些想法,哪里可能是错的,或者我可能做错了什么。
提前感谢:)
发布于 2013-04-11 22:57:38
我已经在负载均衡器上禁用了IPv6,现在一切正常。我猜LVS + IPv6是一个俄罗斯轮盘赌:)
干杯!
https://stackoverflow.com/questions/15946227
复制相似问题