lvs 配置好了之后有问题 请大家帮忙解决

我有三台同样的机器,使用同样的加了"IP: Virtual Server Configuration",也都打了hidden补丁的内核
我在其中一台上装了ipvsdam令两台做真实服务器
可以跳转到页面但不是轮转 有时侯总在一个页面上 用ipvadam看也不对劲
向大家求教 谢谢

这是vserver 的配置脚本
====================================================
#/bin/sh
#file: config_vs.sh

#DR vip
VIP=219.220.237.245

#DR eth0
DIP=219.220.237.241

#real server #1 ip
RS1=219.220.237.242

#real server #2 ip
RS2=219.220.237.243

#DR's GateWay Or Route
GW=219.220.237.254

#Port to open
SERVICE=80

#shell config infomation
cat /proc/sys/net/ipv4/ip_forward
echo "0" >/proc/sys/net/ipv4/ip_forward
echo "1" >/proc/sys/net/ipv4/conf/all/send_redirects
cat /proc/sys/net/ipv4/conf/all/send_redirects
echo "1" >/proc/sys/net/ipv4/conf/default/send_redirects
cat /proc/sys/net/ipv4/conf/default/send_redirects
echo "1" >/proc/sys/net/ipv4/conf/eth0/send_redirects
cat /proc/sys/net/ipv4/conf/eth0/send_redirects

#config DIP
/sbin/ifconfig eth0 ${DIP}
#config VIP
/sbin/ifconfig eth0:0 ${VIP} broadcast ${VIP} netmask 255.255.255.255

#add vip route
/sbin/route add -host ${VIP} dev eth0:0
#add local route
/sbin/route add default gw ${GW}

#show vip configure
/sbin/ifconfig eth0:0

#show route infomation
/sbin/route -n

#clear ipvs
/sbin/ipvsadm –C

#add service
/sbin/ipvsadm -A -t ${VIP}:${SERVICE} -s rr

#add real servers
/sbin/ipvsadm -a -t ${VIP}:${SERVICE} -r ${RS1} -g
/sbin/ipvsadm -a -t ${VIP}:${SERVICE} -r ${RS2} -g

#debug info
ping -c 1 ${RS1}
ping -c 1 ${RS2}

#debug info
/sbin/ipvsadm

#end of config_vs.sh
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
config_vs.sh输出
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
0
1
1
1
SIOCADDRT: File exists
eth0:0 Link encap:Ethernet HWaddr 00:01:01:19:25:5D
inet addr:219.220.237.245 Bcast:219.220.237.245 Mask:255.255.255.255
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0x4000

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
219.220.237.245 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
219.220.237.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 219.220.237.254 0.0.0.0 UG 0 0 0 eth0
Try `/sbin/ipvsadm -h' or '/sbin/ipvsadm --help' for more information.
PING 219.220.237.242 (219.220.237.242) 56(84) bytes of data.
64 bytes from 219.220.237.242: icmp_seq=1 ttl=64 time=3.09 ms

--- 219.220.237.242 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 3.098/3.098/3.098/0.000 ms
PING 219.220.237.243 (219.220.237.243) 56(84) bytes of data.
64 bytes from 219.220.237.243: icmp_seq=1 ttl=64 time=3.00 ms

--- 219.220.237.243 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 3.007/3.007/3.007/0.000 ms
IP Virtual Server version 1.2.1 (size=1048576)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 219.220.237.245:http rr
-> rs2.localdomain:http Route 1 0 0
-> rs1.localdomain:http Route 1 0 0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

下面是real server 的配置脚本
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
#/bin/sh
#file: config_rs.sh这里默认使用网卡eth0,如果想用其它网卡请自行替换即可。
VIP=219.220.237.245 #DR的虚拟服务IP
#DR的eth0真实地址,作用是在配置时测试DR的IP是否有效。但是DR切换后,DIP变了,所以这项取消了。
#DIP=172.30.31.68
#LOCALIP=219.220.237.242 #real server1的真实地址
LOCALIP=219.220.237.243 #real server2的真实地址
GW=219.220.237.254 #real server使用的网关或路由的地址
/sbin/ifconfig eth0 ${LOCALIP} #配置eth0的本地IP
/sbin/route add default gw ${GW} #添加默认路由
/bin/netstat -rn #脚本调试信息
ping -c 1 ${GW} #脚本调试信息,是否可以ping通网关
echo "0" >/proc/sys/net/ipv4/ip_forward
cat /proc/sys/net/ipv4/ip_forward #脚本调试信息,ip_forward是否配置正确
ping -c 1 ${DIP} #脚本调试信息, 是否可以ping通DR的真实地址
ping –c 1 ${VIP} #是否可以ping通虚拟DR的IP
#按照real server的虚拟IP
/sbin/ifconfig lo:0 ${VIP} broadcast ${VIP} netmask 0xffffffff up
#配置出口
/sbin/ifconfig lo:0
#在lo:0上添加去虚拟IP的路由
/sbin/route add -host ${VIP} dev lo:0
/bin/netstat -rn #脚本调试信息
echo "1" >/proc/sys/net/ipv4/conf/all/hidden
cat /proc/sys/net/ipv4/conf/all/hidden #脚本调试信息
echo "1" >/proc/sys/net/ipv4/conf/lo/hidden
cat /proc/sys/net/ipv4/conf/lo/hidden #脚本调试信息
#end of config_rs.sh

============================================

config_rs.sh 输出
SIOCADDRT: File exists
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
219.220.237.245 0.0.0.0 255.255.255.255 UH 0 0 0 lo
219.220.237.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 219.220.237.254 0.0.0.0 UG 0 0 0 eth0
PING 219.220.237.254 (219.220.237.254) 56(84) bytes of data.
64 bytes from 219.220.237.254: icmp_seq=1 ttl=255 time=1.69 ms

--- 219.220.237.254 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.698/1.698/1.698/0.000 ms
0
Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]
[-p pattern] [-s packetsize] [-t ttl] [-I interface or address]
[-M mtu discovery hint] [-S sndbuf]
[ -T timestamp option ] [ -Q tos ] [hop1 ...] destination
ping: unknown host –c
lo:0 Link encap:Local Loopback
inet addr:219.220.237.245 Mask:255.255.255.255
UP LOOPBACK RUNNING MTU:16436 Metric:1

SIOCADDRT: File exists
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
219.220.237.245 0.0.0.0 255.255.255.255 UH 0 0 0 lo
219.220.237.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 219.220.237.254 0.0.0.0 UG 0 0 0 eth0
1
1

Forums: