【原创】centos下自动安装lvs调度器shell脚本 – 21运维
通知: .-...

【原创】centos下自动安装lvs调度器shell脚本

shell 21运维 2095浏览 0评论
#!/bin/bash
#Auto install  director of LVS
#author  swh
echo "Now system  will  install Director of LVS, please wait:"
rpm  -qa  | grep  ipvsadm
ret=$?
if [ $ret -eq 0 ]
	then
	echo  "ipvsadm has be installed,now next step: "
		elif [ $ret -ne 0 ]
		then
		echo "ipvsadm not installed,now installing:"
		yum  -y install  ipvsadm
	else
	echo "error,please check"
fi
kernel_dir="/usr/src/kernels/`uname -r`/"
ln  -s $kernel_dir  /usr/src/linux
echo  -e " kerneldie is :\n$kernel_dir"
mkdir  /home/keepalived
yum  -y install  gcc gcc-c++  openssl openssl-devel
yum  -y install gcc make openssl-devel openssl net-snmp net-snmp-devel popt popt-devel
echo "Now install keepalived:"
wget -c http://www.keepalived.org/software/keepalived-1.2.19.tar.gz
tar zxvf keepalived-1.2.19.tar.gz
cd keepalived-1.2.19
./configure  --prefix=/home/keepalived  --with-kernel-dir=$kernel_dir
make
make install
cd ..
chkconfig  keepalived on
service keepalived start
service keepalived status

ret=$?
if [ $ret -eq 0 ]
then
	cp /home/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
	cp /home/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
	mkdir /etc/keepalived
	ln -s /home/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
	ln -s /home/keepalived/sbin/keepalived /usr/sbin/
	echo  "config keepalived vip and  rip:";
        sed -i '14,$d' /etc/keepalived/keepalived.conf
	echo "`pwd`"
        vip=`cat vip.ip`;	echo "VIP is $vip"
        sed  's/vipaddress/'$vip'/g' vipinstance.conf  >>/etc/keepalived/keepalived.conf
        cat rip.ip |while read rip
        do
        sed 's/ripserver/'$rip'/g' ripserver.conf >>/etc/keepalived/keepalived.conf
        done
        echo  "}" >> /etc/keepalived/keepalived.conf
	echo -e "RIP is :\n `cat  rip.ip`"
	chkconfig  keepalived  on
	service  keepalived start
	ret=$?
	if [ $ret -eq 0 ]
		then
		echo "keepalived install success."
	else
		echo "keepalived install failed"
	fi
else
	echo "keepalived install failed,please check."
fi

下载以后解压执行sh lvsDirector.sh即可 。 注意该脚本基于DR模式,测试平台在centos 6.5 上边。经测试不适合于centos 7安装配置。
swhlvs

转载请注明:21运维 » 【原创】centos下自动安装lvs调度器shell脚本

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址