分类: LINUX
2008-04-28 22:12:44
确定LVS使用DR或/tun模式,请对照上面的配置,本例使用DR模式
1.配置LVS directorserver 脚本
#!/bin/sh
VIP=192.168.8.11
RIP1=192.168.8.6
RIP2=192.168.8.5
/etc/rc.d/init.d/functions
case "$1" in
start)
echo "start LVS of DirectorServer"
#Set the Virtual IP Address
/sbin/ifconfig eth0:1 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP dev eth0:1
#Clear IPVS Table
/sbin/ipvsadm -C
#Set Lvs
/sbin/ipvsadm -A -t $VIP:80 -s rr
/sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g
/sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g
#Run Lvs
/sbin/ipvsadm
;;
stop)
echo "close LVS Directorserver"
/sbin/ipvsadm -C
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
2. realserver端同样使用上面的配置文件就可以。
3.安装heartbeat
3.1 安装
tar -zxvf libnet.tar.gz
cd libnet
。/configure
make
make install
groupadd -g 694 haclient
useradd -u 694 -g haclient hacluster
tar zxf heartbeat-1.99.4.tar.gz
cd heartbeat-1.99.4
。/ConfigureMe configure
make
make install
cp doc/ha.cf doc/haresources doc/authkeys /etc/ha.d/
cp ldirectord/ldirectord.cf /etc/ha.d/
3.2配置主文件/etc/ha.d/ha.cf
logfile /var/log/ha-log
keepalive 2
deadtime 60
warntime 10
initdead 120
udpport 694
bcast eth0 # Linux
auto_failback on
ping_group group1 192.168.8.2 192.168.8.3
respawn root /usr/lib/heartbeat/ipfail
apiauth ipfail gid=root uid=root
hopfudge 1
use_logd yes
node test7
node test8
crm on
3.3资源文件/etc/ha.d/ haresources
test7 192.168.8.11 httpd
设置test7为主节点,集群的ip地址为192.168.8.11 集群服务有httpd