-
配置文件
cat > /etc/lvs_dr.conf <<EOF
# LVS DR VIP configfile
VIPs="
192.168.0.2
192.168.0.3
"
EOF
-
lvs_dr.sh
#!/bin/sh
# name : lvs_dr.sh
# auther : YuanXing
# update : 2013-06-21
# description : start realserver
# chkconfig: 2345 55 25
VIPs="$VIPs"
CONF=/etc/lvs_dr.conf
. /etc/rc.d/init.d/functions
do_start(){
echo "Start LVS of RealServer"
VIPs=
if [ -f "$CONF" ];then
. $CONF
else
echo "Error:config file $CONF not exist!"
return 1
fi
if [ -z "$VIPs" ];then
echo "Error:VIPs is empty!"
return 1
fi
lab=0
for vip in `echo "$VIPs"|grep -vE "^#|^$"`
do
[ -z "$vip" ] && echo "Error vip:$vip" && continue
/sbin/ifconfig lo:$lab $vip broadcast $vip netmask 255.255.255.255 up
lab=`expr $lab + 1`
done
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
}
do_stop(){
echo "Close LVS RealServer"
for dev in `ifconfig|grep ^lo:|awk '{print $1}'`
do
/sbin/ifconfig $dev down
done
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
}
case "$1" in
start)
do_start
exit $?
;;
stop)
do_stop
;;
restart)
do_stop
do_start
;;
status)
ip addr show|grep 'lo:'
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
-
快速部署
# ---------------------------------------------------------
cat > /etc/lvs_dr.conf <<EOF
# LVS DR VIP configfile
VIPs_pre_test="
192.168.0.2
192.168.0.3
192.168.0.4
192.168.0.5
192.168.0.6
192.168.0.7
192.168.0.8
192.168.0.9
192.168.0.59"
VIPs_IDC="
192.168.0.53
192.168.0.54
192.168.0.55
192.168.0.56
192.168.0.57
192.168.0.58
192.168.0.59
192.168.0.60
192.168.0.61
192.168.0.62
192.168.0.63"
VIPs=$VIPs_pre_test
EOF
# ---------------------------------------------------------
echo -e "H4sIAJ/yw1EAA51UbY8SMRD+vr9ibiGHaKAsd/gBgl8uZ2Ji1Ei8aIxA2e1Cw167abvACfx3py1w
exwqSkKAmXle5mWpXJAJF0TPggoIes8AoAvZQo8S1XRBWpgZUxj8VlDxlYspxoo8oYZhrN2Krhqt
1412hNGE6Vjx3HApMKUNVQYUo5lmasEUFsSzeSxFyqcIvLruQKcD7U4AENy9+6T7YRjcfPzwtk+Y
icnOgS23BU1wURU3E8IFN/iRFiK2UjqAIJEjJ/eivsZqABbPJIQD5+D93QBkCp/RyMAZCV2Jk3Tf
eArfoZFCWLXyIfzoYcPCpeyrCS7uebGXQ8KL3ColVde3BSnPmC8HIQ2wFdfmIjwgFDOFEhCBi6S8
JP8T5a2lZ/JlFVsAXAO7z83DCd4ybUYn/ZYPSAULngMXMPZsXmkzVSyHxuIWwmFlM6yGY1eeyAPv
zheC0RZcXpbNWMquT2EC+zdcFI/DIdpeFU93g8lkt4qOwAJgoiRNYqqN/ymYuad6jqfQaZbeeGQH
NtvMmK1yBY7lFUR7r4KVFh6F8IbkSsZEP2iCvITni2tiPZBMEqryEZ8KqcqY9t8xVAiJx3auEs2y
f5fagw5aW3/UMn960zeZ1Mzd9PFB2zUnbOHWvJ+7X/EQp7+hyznU1rniAscebWvPln20sarlSuRS
nBp06z8GfQbmxKD/hPrtoM8BlQaNuADPkeGp4165CNx/SX3XuP9n8ewrbsA/VL1eYJdTKpL5PqHY
McEu94TMMVBTaF+HDwJNEgV6Jpd+bTVcW21f+rJe6u+LplPWhWoL1o5vYxU2O9mNZ92Gj5ajPQvT
NA5+Abwq10byBQAA"|base64 -d|gzip -d> /etc/init.d/lvs_dr.sh
chmod 755 /etc/init.d/lvs_dr.sh
chkconfig --add lvs_dr.sh
chkconfig lvs_dr.sh on
chkconfig --list lvs_dr.sh
service lvs_dr.sh restart
service lvs_dr.sh status
# ---------------------------------------------------------