Chinaunix首页 | 论坛 | 博客
  • 博客访问: 346091
  • 博文数量: 93
  • 博客积分: 2322
  • 博客等级: 大尉
  • 技术积分: 1600
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-27 10:23
文章分类

全部博文(93)

文章存档

2018年(12)

2012年(81)

分类: LINUX

2012-08-27 17:09:25

操作系统centos5.5 32
cat haresources    | grep -v ^# 
primary.localdomain lvs ldirectord 
 
 
cat authkeys    | grep -v ^# 
auth 1 
1 sha1 HI! 
 
 
cat ldirectord.cf    | grep -v ^# 
checktimeout=3 
checkinterval=1 
fallback=127.0.0.1:80 
autoreload=yes 
logfile="/var/log/ldirectord.log" 
logfile="local0" 
emailalert="" 
emailalertfreq=3600 
emailalertstatus=all 
quiescent=no 
virtual=192.168.213.1:80 
                 real=192.168.213.130:80 gate 
                 real= 192.168.213.131:80 gate 
                fallback=127.0.0.1:80 gate 
                service=http 
                scheduler=wrr 
                 persistent=5 
                 protocol=tcp 
                checktype=connect 
                checkport=80 
 
 
echo -e "--------------------------------------------------------------------------------------------------------------------" 
cat /etc/ha.d/lvs 
lvs scripts 
#!/bin/bash   
# description: start LVS of DirectorServer   
#Written by :NetSeek
GW=192.168.1.254 
## website director vip 
GW=192.168.213.1 
WEB_VIP=192.168.213.131 
WEB_RIP1=192.168.213.130 
#WEB_RIP2=192.168.1.110 
 
. /etc/rc.d/init.d/functions   
 
logger $0 called with $1   
 
case "$1" in 
   
start) 
   
/sbin/iptables -F 
/sbin/iptables -Z 
/sbin/ipvsadm --set 30 5 60 
  /sbin/ifconfig eth1:0 $WEB_VIP broadcast $WEB_VIP netmask 255.255.255.255 up   
/sbin/route add -host $WEB_VIP dev eth1:0   
/sbin/ipvsadm -A -t $WEB_VIP:80 -s wrr -p 3   
/sbin/ipvsadm -a -t $WEB_VIP:80 -r $WEB_RIP1:80 -g -w 1   
/sbin/ipvsadm -a -t $WEB_VIP:80 -r $WEB_RIP2:80 -g -w 1   
touch /var/lock/subsys/ipvsadm >/dev/null 2>&1   
/sbin/arping -I eth1 -c 5 -s $WEB_VIP $GW >/dev/null 2>&1   
 
;;   
 
stop)   
/sbin/ipvsadm -C   
/sbin/ipvsadm -Z   
ifconfig eth1:0 down   
route del $WEB_VIP >/dev/null 2>&1   
rm -rf /var/lock/subsys/ipvsadm >/dev/null 2>&1   
/sbin/arping -I eth1 -c 5 -s $WEB_VIP $GW   
echo "ipvsadm stoped"   
 
;; 
status)   
 
if [ ! -e /var/lock/subsys/ipvsadm ];    then 
echo "ipvsadm is stoped"   
exit 1   
else   
ipvsadm -ln   
echo "..........ipvsadm is OK."   
fi 
   
;; 
   
*)   
echo "Usage: $0 {start|stop|status}"   
exit 1   
esac   
exit 0 
echo -e "--------------------------------------------------------------------------------------------------------------------" 
mv          /etc/ha.d/lvs             /etc/init.d/        ;    chmod         755      /etc/init.d/lvs         ;   ln     -s    /etc/init.d/lvs 
/etc/ha.d/resource.d/ ; cp    /etc/init.d/lvs    /etc/ha.d/ 
chkconfig heartbeat on 
#------------------------------------------------------------------------------------------------------------------------------- 
#------------------------------------------------------------------------------------------------------------------------------- 
backup server 
yum    -y install    libnet 
yum    -y install    heartbeat-* 
yum    -y install    heartbeat 
yum    -y install    ipvsadm 
 
rm -f /etc/hosts && scp -P 22 /etc/hosts 
rm -fr /etc/ha.d/    &&    scp -P 22 -r        /etc/ 
rm   -f  /etc/ha.d/resource.d/lvs      &&   cp   /etc/ha.d/lvs   /etc/init.d/     &&    ln  -s  /etc/init.d/lvs 
/etc/ha.d/resource.d/ 
sed -i 's/ucast eth0 172.16.0.101/ucast eth0 172.16.0.100/' /etc/ha.d/ha.cf 
sed -i 's/ping 172.16.0.101/ping 172.16.0.100/' /etc/ha.d/ha.cf 
chkconfig heartbeat on 
#------------------------------------------------------------------------------------------------------------------------------- 
#------------------------------------------------------------------------------------------------------------------------------- 
real1 client: 
cat /root/real.sh 
#/bin/sh  
VIP=192.168.213.1 
source /etc/rc.d/init.d/functions  
case "$1" in  
start)  
echo "start LVS of RealServer"  
/sbin/ifconfig lo:0 ${VIP} broadcast ${VIP} netmask 255.255.255.255 up  
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  
 ;;  
stop)  
/sbin/ifconfig lo:0 down  
echo "Close LVS of RealServer"  
echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore  
echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce  
echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore  
echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce  
 ;;  
*)  
echo "wrong,please use start|stop"  
exit 1  
esac 
#------------------------------------------------------------------------------------------------------------------------------- 
chmod 755 /root/real.sh 
./real.sh start 
#------------------------------------------------------------------------------------------------------------------------------- 
#------------------------------------------------------------------------------------------------------------------------------- 
real2 client: 
scp -P 22     .     
chmod 755 /root/real.sh 
./real.sh start 
#------------------------------------------------------------------------------------------------------------------------------- 

#------------------------------------------------------------------------------------------------------------------------------- 
test 
start    primary    and    backup    Priority    primary    backup 
/etc/init.d/heartbeat start 
primary server enter    awk '/Running/{print $0}'    /var/log/ha-log 
show   
2011/12/29_02:58:24 info: Running /etc/ha.d/resource.d/lvs    start 
2011/12/29_02:58:31 info: Running /etc/ha.d/resource.d/ldirectord    start 

Success 
Or failure 
#------------------------------------------------------------------------------------------------------------------------------- 
backup server enter    awk '/remote*/{print $0}' /var/log/ha-log 
show   
2011/12/29_03:12:01 info: remote resource transition completed 

Success 
Or failure 
ipvsadm 
查看真实主机 

阅读(1338) | 评论(0) | 转发(0) |
0

上一篇:oraclei11gr2install

下一篇:cacti install notebook

给主人留下些什么吧!~~