全部博文(178)
分类: LINUX
2009-09-06 22:06:00
cat ha.cf
logfile /var/log/ha-log
#logfacility local0
keepalive 3
deadtime 9
warntime 10
initdead 120
udpport 694
bcast eth1
auto_failback on
node LVS1
node LVS2
#hopfudge 1crm on
ping 121.121.121.121
#ping_group group1
#ping_group group1 172.16.64.133 172.16.64.132
respawn root /usr/local/lib/heartbeat/ipfail
apiauth ipfail gid=root uid=root
#crm on
[root@LVS
#LVS1 IPaddr::121.121.x.x lvsDR ldirectord
#LVS1 IPaddr::121.14.4.38/27/121.14.4.48 lvsDR ldirectord
LVS1 IPaddr:: lvsDR ldirectord
LVS1 IPaddr::VIP2 lvsDR ldirectord
ldirectord.cf
cat ldirectord.cf
#!/bin/bash
# Global Directives
checktimeout=9
checkinterval=3
fallback=127.0.0.1:80
autoreload=yes
logfile="/var/log/ldirectord.log"
quiescent=no
emailalert="iXX@163.com"
emailalertfreq=3600
emailalertstatus=all
# A sample virual with a fallback that will override the gobal setting
virtual=121.14.4.38:80
#real=121.14.4.43:80 gate
real=REAL1:80 [U3]
real=REAL2:80[U4]
fallback=127.0.0.1:80 [U5]
service=http
request="ld_test.asp"
receive="ok"
scheduler=rr
protocol=tcp
virtual=121.14.4.48:80
#real=REAL_1:80 gate
real=REAL_2:80 gate
fallback=127.0.0.1:80 gate
service=http
request="ld_test.asp"
receive="ok"
scheduler=rr
protocol=tcp
cat authkeys
auth 2
2 sha1 bnetbarhearbeat
LVS的脚本 :
cat /etc/init.d/lvsDR
#!/bin/sh
# description: start LVS of Directorserver
SQUID_VIP=1.1.2.2
WEB_VIP=1.1.1.2
SQUID_RIP1=1.1.1.4
SQUID_RIP2=1.1.2.3
WEB_RIP1=1.1.1.3
WEB_RIP2=1.1.1.4
GW=1.1.1.1
. /etc/rc.d/init.d/functions
case "$1" in
start)
echo " start LVS of DirectorServer"
# set the Virtual IP Address
/sbin/ifconfig eth0:0 $SQUID_VIP broadcast $SQUID_VIP netmask 255.255.255.255 up
/sbin/route add -host $SQUID_VIP dev eth0:0
/sbin/ifconfig eth0:1 $WEB_VIP broadcast $WEB_VIP netmask 255.255.255.255 up
/sbin/route add -host $WEB_VIP dev eth0:1
#Clear IPVS table
/sbin/ipvsadm -C
#set SQUID LVS
/sbin/ipvsadm -A -t $SQUID_VIP:80 -s rr
/sbin/ipvsadm -a -t $SQUID_VIP:80 -r $SQUID_RIP1:80 -g
/sbin/ipvsadm -a -t $SQUID_VIP:80 -r $SQUID_RIP2:80 -g
#set WEB LVS
/sbin/ipvsadm -A -t $WEB_VIP:80 -s rr
/sbin/ipvsadm -a -t $WEB_VIP:80 -r $WEB_RIP1:80 -g
/sbin/ipvsadm -a -t $WEB_VIP:80 -r $WEB_RIP2:80 -g
#Run LVS
/sbin/ipvsadm
#end
;;
stop)
echo "close LVS Directorserver"
/sbin/ipvsadm -C
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
总结, LVS+HEARTBEAT+LDIRECTORD
HA.CF
HARESOUCE
LDIRECTORD
脚本 lvsDR
一些相关加载的命令