ipvsadm发现不了辅lvs

参考的
http://linux.chinaunix.net/bbs/thread-1014393-1-1.html
双机lvs-ha
主服务器+真实的web服务器 :192.168.2.25 一台主机
备服务器+ 真实的web服务器:192.168.2.39 一台主机
Lvs director 配置在主服务器上,根据源地址分配服务器。
集群的虚拟ip为60.*.184,初始分配在主服务器的eth0, 主服务器宕机后,ip由备份服务器接管,分配在备份服务器的eth0.
现在的问题是
[root@wangchangling ~]# ipvsadm
IP Virtual Server version 1.2.0 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 60.*.184:http sh
-> 60.*.168:http Local 1 0 0
只能负载到这一台主机! 不能发现辅的WEB加LVS
配置文件如下:主
[root@wangchangling ~]# cat /etc/hosts
192.168.2.25 wangchangling
192.168.2.39 yanshu
127.0.0.1 wangchangling localhost.localdomain localhost
[root@wangchangling ha.d]# cat ha.cf |sed '/^#/d'
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 40
ucast eth1 192.168.2.39
auto_failback on
node wangchangling
node yanshu
ping_group group1 192.168.2.25 192.168.2.39
respawn root /usr/lib/heartbeat/ipfail
apiauth ipfail gid=root uid=root
# cat authkeys 这个权限是600
auth 1
1 crc
说明test.html内容为Test且都能访问http://real1/test.html http://real2/test.html
[root@wangchangling ha.d]# cat ldirectord.cf
checktimeout=3
checkinterval=2
fallback=127.0.0.1:80
autoreload=no
logfile="/var/log/ldirectord.log"
quiescent=no
virtual=60.*184:80
real=60.*:80 gate
real=60.*:80 gate
service=http
request="test.html"
receive="Test"
scheduler=sh
protocol=tcp
checktype=negotiate
checkport=80
[root@wangchangling ha.d]# cat haresources
wangchangling IPaddr::60.*.184 lvsdr-basic ldirectord
[root@wangchangling ha.d]# cat /etc/init.d/lvsdr-basic
#!/bin/sh
VIP=60.*.184
RIP1=60.*.168
RIP2=60.*.178
###########################
# ifconfig a
#
#/sbin/ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up
#
############################
/sbin/route add -host $VIP dev eth0:0
echo "1" > /proc/sys/net/ipv4/ip_forward
[root@wangchangling ha.d]# cat ha.cf |sed '/^#/d'
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 40
ucast eth1 192.168.2.39
auto_failback on
node wangchangling
node yanshu
ping_group group1 192.168.2.25 192.168.2.39
respawn root /usr/lib/heartbeat/ipfail
apiauth ipfail gid=root uid=root


[root@yanshu ha.d]# cat ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 40
ucast eth1 192.168.2.25 #这里是区别
auto_failback on
node wangchangling
node yanshu
ping_group group1 192.168.2.25 192.168.2.29
respawn root /usr/lib/heartbeat/ipfail
apiauth ipfail gid=root uid=root
[root@yanshu ha.d]# cat haresources
wangchangling switchdr IPaddr::60.*.184
[root@yanshu ha.d]# cat /etc/init.d/switchdr
#!/bin/sh
# description: close lo0 and arp_ignore
VIP=60.*.184

. /etc/rc.d/init.d/functions

case "$1" in
start)
echo "************* start director server and close tunl ***********"
ifconfig lo:0 down
echo 0>/proc/sys/net/ipv4/conf/all/arp_announce
;;
stop)
echo "start Real Server"
ifconfig eth0:0 down
ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $VIP up
/sbin/route add -host $VIP dev lo:0

echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p
;;
*)
echo "Usage: switchdr {start|stop}"
exit 1
esac
日志如下:启动主LVS的heartbeat
Mar 25 17:52:53 wangchangling heartbeat: [8455]: info: Version 2 support: false
Mar 25 17:52:53 wangchangling heartbeat: [8455]: WARN: Logging daemon is disabled --enabling logging daemon is recommended
Mar 25 17:52:53 wangchangling heartbeat: [8455]: info: **************************
Mar 25 17:52:53 wangchangling heartbeat: [8455]: info: Configuration validated. Starting heartbeat 2.1.3
Mar 25 17:52:53 wangchangling heartbeat: [8456]: info: heartbeat: version 2.1.3
Mar 25 17:52:54 wangchangling heartbeat: [8456]: info: Heartbeat generation: 1237807394
Mar 25 17:52:54 wangchangling heartbeat: [8456]: info: glib: ucast: write socket priority set to IPTOS_LOWDELAY on eth1
Mar 25 17:52:54 wangchangling heartbeat: [8456]: info: glib: ucast: bound send socket to device: eth1
Mar 25 17:52:54 wangchangling heartbeat: [8456]: info: glib: ucast: bound receive socket to device: eth1
Mar 25 17:52:54 wangchangling heartbeat: [8456]: info: glib: ucast: started on port 694 interface eth1 to 192.168.2.39
Mar 25 17:52:54 wangchangling heartbeat: [8456]: info: glib: ping group heartbeat started.
Mar 25 17:52:54 wangchangling heartbeat: [8456]: info: G_main_add_TriggerHandler: Added signal manual handler
Mar 25 17:52:54 wangchangling heartbeat: [8456]: info: G_main_add_TriggerHandler: Added signal manual handler
Mar 25 17:52:54 wangchangling heartbeat: [8456]: info: G_main_add_SignalHandler: Added signal handler for signal 17
Mar 25 17:52:54 wangchangling heartbeat: [8456]: info: Local status now set to: 'up'
Mar 25 17:52:55 wangchangling heartbeat: [8456]: info: Link yanshu:eth1 up.
Mar 25 17:52:55 wangchangling heartbeat: [8456]: info: Status update for node yanshu: status active
Mar 25 17:52:55 wangchangling harc[8465]: info: Running /etc/ha.d/rc.d/status status
Mar 25 17:52:55 wangchangling heartbeat: [8456]: info: Link group1:group1 up.
Mar 25 17:52:55 wangchangling heartbeat: [8456]: info: Status update for node group1: status ping
Mar 25 17:52:55 wangchangling heartbeat: [8456]: info: Comm_now_up(): updating status to active
Mar 25 17:52:55 wangchangling heartbeat: [8456]: info: Local status now set to: 'active'
Mar 25 17:52:55 wangchangling heartbeat: [8456]: info: Starting child client "/usr/lib/heartbeat/ipfail " (0,0)
Mar 25 17:52:55 wangchangling heartbeat: [8482]: info: Starting "/usr/lib/heartbeat/ipfail " as uid 0 gid 0 (pid 8482)
Mar 25 17:52:56 wangchangling heartbeat: [8456]: info: remote resource transition completed.
Mar 25 17:52:56 wangchangling heartbeat: [8456]: info: remote resource transition completed.
Mar 25 17:52:56 wangchangling heartbeat: [8456]: info: Local Resource acquisition completed. (none)
Mar 25 17:52:56 wangchangling heartbeat: [8456]: info: yanshu wants to go standby [foreign]
Mar 25 17:52:57 wangchangling heartbeat: [8456]: info: standby: acquire [foreign] resources from yanshu
Mar 25 17:52:57 wangchangling heartbeat: [8486]: info: acquire local HA resources (standby).
Mar 25 17:52:57 wangchangling ResourceManager[8499]: info: Acquiring resource group: wangchangling IPaddr::60.28.211.184 lvsdr-basic ldirectord
Mar 25 17:52:57 wangchangling IPaddr[8526]: INFO: Resource is stopped
Mar 25 17:52:57 wangchangling ResourceManager[8499]: info: Running /etc/ha.d/resource.d/IPaddr 60.*.184 start
Mar 25 17:52:57 wangchangling IPaddr[8600]: INFO: Using calculated nic for 60.*.184: eth0
Mar 25 17:52:57 wangchangling IPaddr[8600]: INFO: Using calculated netmask for 60.*.184: 255.255.255.224
Mar 25 17:52:57 wangchangling IPaddr[8600]: INFO: eval ifconfig eth0:0 60.*.184 netmask 255.255.255.224 broadcast 60.28.211.191
Mar 25 17:52:57 wangchangling IPaddr[8583]: INFO: Success
Mar 25 17:52:57 wangchangling ResourceManager[8499]: info: Running /etc/init.d/lvsdr-basic start
Mar 25 17:52:57 wangchangling ResourceManager[8499]: info: Running /etc/ha.d/resource.d/ldirectord start
Mar 25 17:52:58 wangchangling heartbeat: [8486]: info: local HA resource acquisition completed (standby).
Mar 25 17:52:58 wangchangling heartbeat: [8456]: info: Standby resource acquisition done [foreign].
Mar 25 17:52:58 wangchangling heartbeat: [8456]: info: Initial resource acquisition complete (auto_failback)
Mar 25 17:52:58 wangchangling heartbeat: [8456]: info: remote resource transition completed.
Mar 25 17:53:03 wangchangling ipfail: [8482]: info: Ping node count is balanced.
Mar 25 17:53:03 wangchangling ipfail: [8482]: info: Giving up foreign resources (auto_failback).
Mar 25 17:53:03 wangchangling ipfail: [8482]: info: Delayed giveup in 4 seconds.
Mar 25 17:53:07 wangchangling ipfail: [8482]: info: giveup() called (timeout worked)
Mar 25 17:53:08 wangchangling heartbeat: [8456]: info: wangchangling wants to go standby [foreign]
Mar 25 17:53:08 wangchangling heartbeat: [8456]: info: standby: yanshu can take our foreign resources
Mar 25 17:53:08 wangchangling heartbeat: [8773]: info: give up foreign HA resources (standby).
Mar 25 17:53:08 wangchangling heartbeat: [8773]: info: foreign HA resource release completed (standby).
Mar 25 17:53:08 wangchangling heartbeat: [8456]: info: Local standby process completed [foreign].
Mar 25 17:53:09 wangchangling heartbeat: [8456]: WARN: 1 lost packet(s) for [yanshu] [1518:1520]
Mar 25 17:53:09 wangchangling heartbeat: [8456]: info: remote resource transition completed.
Mar 25 17:53:09 wangchangling heartbeat: [8456]: info: No pkts missing from yanshu!
Mar 25 17:53:09 wangchangling heartbeat: [8456]: info: Other node completed standby takeover of foreign resources.

Forums: