我正在使用ldirectord負載平衡兩個HTTP服務器。在負載均衡器框中,我有以下網絡配置:ldirectord NAT負載均衡不適用於協商檢查
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 = "[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規則,使內廷按預期方式工作:
# 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在存活測試期間所做的工作?
一般來說,有人可以闡明一些想法或給我一些想法什麼可能是錯的,或者我可能做錯了什麼。
感謝提前:)