急手问题

lvs-nat 使用算法rr,轮导一周正常,当第二周时浏览器进入请求等待状态,
ipvsadm -L -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.1.190:80 rr
-> 192.168.3.13:80 Masq 1 0 1
-> 192.168.3.12:80 Masq 1 0 1
-> 192.168.3.11:80 Masq 1 0 1
-> 192.168.3.10:80 Masq 1 0 1

ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:76:7E:6B:6B
inet addr:192.168.1.168 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:76ff:fe7e:6b6b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:20030 errors:0 dropped:0 overruns:0 frame:0
TX packets:5020 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2196344 (2.0 MiB) TX bytes:706876 (690.3 KiB)
Base address:0xa000 Memory:fa000000-fa020000

eth0:1 Link encap:Ethernet HWaddr 00:0C:76:7E:6B:6B
inet addr:192.168.1.190 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xa000 Memory:fa000000-fa020000

eth0:2 Link encap:Ethernet HWaddr 00:0C:76:7E:6B:6B
inet addr:192.168.3.1 Bcast:255.255.255.0 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xa000 Memory:fa000000-fa020000

eth1 Link encap:Ethernet HWaddr 00:0C:76:7E:6B:6A
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:76ff:fe7e:6b6a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3688 errors:0 dropped:0 overruns:0 frame:0
TX packets:3789 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:916577 (895.0 KiB) TX bytes:945486 (923.3 KiB)
Base address:0xc000 Memory:fd000000-fd020000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:180 errors:0 dropped:0 overruns:0 frame:0
TX packets:180 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:14676 (14.3 KiB) TX bytes:14676 (14.3 KiB)

通过heartbeat 调用ipvsnatd脚本实现ha.

#!/bin/bash
#
# LVS script
#
# chkconfig: 2345 99 90
# description: lvs-nat script
#
case $1 in
start)
# Bring up the VIP (Normally this should be under Heartbeat.s control.)
#/sbin/ifconfig eth0:1 209.100.100.3 netmask 255.255.255.0 up #如果使用heartbeat设置了资源ip或者iptakeover,这里就不用再设置
/sbin/ifconfig eth0:2 192.168.3.1 broadcast 255.255.255.0 up
# Since this is the Director we must be
# able to forward packets.
echo 1 > /proc/sys/net/ipv4/ip_forward

# Clear all iptables rules.
/sbin/iptables -F

# Reset iptables counters.
/sbin/iptables -Z

# Clear all ipvsadm rules/services.
/sbin/ipvsadm -C

# Add an IP virtual service for VIP 192.168.1.190 port 80
/sbin/ipvsadm -A -t 192.168.1.190:80 -s rr

# Now direct packets for this VIP to
# to the Real Server IP (RIP) inside the cluster
/sbin/ipvsadm -a -t 192.168.1.190:80 -r 192.168.3.10 -m -w 1
/sbin/ipvsadm -a -t 192.168.1.190:80 -r 192.168.3.11 -m -w 1
/sbin/ipvsadm -a -t 192.168.1.190:80 -r 192.168.3.12 -m -w 1
/sbin/ipvsadm -a -t 192.168.1.190:80 -r 192.168.3.13 -m -w 1
;;
stop)
# Stop forwarding packets
echo 0 > /proc/sys/net/ipv4/ip_forward

# Reset ipvsadm
/sbin/ipvsadm -C

# Bring down the VIP interface
#ifconfig eth0:1 down
/sbin/ifconfig eth0:2 down

;;
status)
/sbin/ipvsadmin -L -n --stats
*)
echo "Usage: $0 {start|stop|status}"
;;

esac

大家帮我分析原因,与解决方法。
谢谢!

Forums:

Imspserive brain power at work! Great answer!