我正在使用ldirectord负载平衡两个HTTP服务器。 在负载均衡器框中,我有以下networkingconfiguration:
eth0用于内部目的,根本不参与负载均衡。 在eth1上,我configuration了机器的公共IP(用于来自其他内部networking的访问)和负载平衡器的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负载均衡的configuration:
# cat /etc/ha.d/ldirectord.cf autoreload = yes quiescent = yes checkinterval = 10 negotiatetimeout = 10 checktimeout = 5 emailalert = "[email protected]" 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
现在问题是活着的检查不能按预期工作。 尽pipe服务器在线(我可以ping通它们),但是ldirector并没有看到它,并将它们标记为down。
如果我使用ping检查一切工作正常,但我们需要协商更全面的服务检查(服务器可以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为这件事)活着的页面。 我试过从其他两台机器,从不同的子网wgetting它,它工作正常! 我意识到负载均衡器框中有些东西不行。
然后我closures了ldirectord并再次尝试了wget。 这一次它工作。
所以在我看来,ldirector不知何故停止访问真实服务器上的活动页面? 这似乎很奇怪和不合逻辑。 那么我能做什么错?
问题不是由iptables规则引起的,因为当我删除它们时,alive.htm页面仍然不可用。
真实的服务器都可以从负载平衡器(pingable)访问。 我有一些ldirectord的configuration问题吗?
我怎样才能确定ldirectord在存活testing期间正在做什么?
一般来说,有人可以阐明一些想法,或给我一些想法什么可能是错的,或者我可能做错了什么。
提前致谢 :)
我在负载平衡器上禁用了IPv6,现在一切正常。 我猜LVS + IPv6是一个俄罗斯rooulette 🙂
干杯!