大家帮忙!看看是什么问题!不知道为什么总是只连接一个real server!

本人刚刚接触LVS,有很多东西不是很了解,请大家指点!先谢谢了!

我用一个switch连接了5台电脑,其中1个装的是WinXP做为Client测试,其他4台装的是Linux Debian:有2个做为LS MASTER 和LS BACKUP,剩下的2个是real server.如图:Load Balancer & FailOver

192.168.2.50是VIP。
________
| |
| client |
|________|
192.168.2.x
|
|
192.168.2.50 (eth0:0) __________ | __________ 192.168.2.50 (eth0:0)
| | | | |
|LS Master |---|---|LS Backup |
192.168.2.15 (eth0) |__________| | |__________| 192.168.2.45 (eth0)
|
|
-----------------------------------
| |
| |
192.168.2.23 (eth0) 192.168.2.43(eth0)
_____________ _____________
| | | |
| real-server | | real-server |
|_____________| |_____________|

我在2个LS上装了ipvsadm,keepalived,heartbeat,都是最新版本。
下面是配置文件:
/etc/lvs.conf

ipvsadm -A -t 192.168.2.50:80 -s wlc
——————————————————
/etc/sysctl.conf 里加了

net.ipv4.ip_forward = 1
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.eth0.arp_announce = 2

然后执行:sysctl -p /etc/sysctl.conf
——————————————————
/etc/ha.d/ha.cf内容如下:

keepalive 2
logfile /var/log/ha-log
deadtime 10
hopfudge 1
udpport 964
ucast 192.168.2.45 eth0 #LSBackup为ucast 192.168.2.15 eth0
logfacility local0
node LSMaster
node LSBackup
——————————————————
/etc/ha.d/haresources内容如下:

LSMaster IPaddr::192.168.2.50/24/eth0 keepalived #LSBackup为LSBackup IPaddr::192.168.2.50/24/eth0 keepalived
——————————————————
/etc/ha.d/ authkeys内容如下:

auth 2
1 md5 "cluster test"
2 crc
——————————————————
/etc/keepalived/keepalived.conf内容如下:

global_defs {
router_id DEV
}
vrrp_instance VI_1 {
state MASTER #LSBackup为:state BACKUP
interface eth0
virtual_router_id 51
priority 100 #LSBackup为:priority 99
advert_int 10
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.2.50
}
}
virtual_server 192.168.2.50 80 {
delay_loop 10
lb_algo wlc
lb_kind DR
persistence_timeout 5
protocol TCP
real_server 192.168.2.23 80 {
TCP_CHECK {
}
}
real_server 192.168.2.43 80 {
TCP_CHECK {
}
}
}

2个real server配置如下:

ifconfig dummy0 up
ifconfig dummy0 192.168.2.50 netmask 255.255.255.0 broadcast 192.168.2.255 up
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 1 > /proc/sys/net/ipv4/conf/dummy0/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/dummy0/arp_announce

完了。
在2个LS上运行 /etc/init.d/heartbeat start

我看了/var/log/messages
运行正常,但是在Client上打开网页http://192.168.2.50 总是显示43的网页,要是把43从switch上拔掉,就可以显示23的网页,再把43插上去,还是一直显示23的网页。

不知道为什么,请大家指点。谢谢!!

Forums:

对于一段时间内来自于同一IP 的访问请求总是被转到同一个REAL SERVER上.coolbaby

你若想轮殉的话把 persistence_timeout 5
注释掉