1 cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
2 cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/
3 cp /usr/local/sbin/keepalived /usr/sbin/
4 mkdir /etc/keepalived -p
5 cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
7、启动并查看keepalived
[root@LVS-DR-Backup script]# /etc/init.d/keepalived start
正在启动 keepalived: [确定]
[root@LVS-DR-Backup script]# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.200.100:https rr persistent 50
-> 192.168.201.100:https Masq 1 0 0
TCP 10.10.10.2:connlcli rr persistent 50
-> 192.168.200.2:connlcli Masq 1 0 0
-> 192.168.200.3:connlcli Masq 1 0 0
TCP 10.10.10.3:connlcli rr persistent 50
-> 192.168.200.4:connlcli Masq 1 0 0
-> 192.168.200.5:connlcli Masq 1 0 0
[root@LVS-DR-Backup script]#
8、至此安装完成,下一章,keepalived.conf详解。
附:lvs和keepalived一键安装脚本
#!/bin/bash
# Filename :Install_lvs.sh
# Description : 安装lvs+keepalived软件脚本
#参数设置
Toolsdir=/home/test/tools
IPVSADM=ipvsadm-1.26
Kernel=uname -r
KEEPALIVED=keepalived-1.2.23
#定义安装ipvsadm函数
function IPvsadm(){
cd ${Toolsdir}
#下载ipvsadm软件
[ ! -f ${IPVSADM}.tar.gz ] && wget ${IPVSADM}.tar.gz
#安装依赖包
yum install -y popt libnl-devel popt-static
#解压并安装ipvsadm
tar zxf ${IPVSADM}.tar.gz
if [ $? == 0 ];then
cd ${IPVSADM}
ln -s /usr/src/kernel/${Kernel}/ /usr/src/linux
make
if [ $? == 0 ];then
make install
if [ $? == 0 ];then
echo "IPVSADM INSTALL SUCCESSFUL."
else
echo "make install error."
eixt 0
sleep 5
fi
else
echo "make error."
exit 1
fi
else
echo "tar error."
exit 2
fi
}
#定义安装keepalived函数
function Keepalived(){
#下载软件
cd ${Toolsdir}
[ ! -f ${KEEPALIVED}.tar.gz ] && wget ${KEEPALIVED}.tar.gz
#安装依赖包
yum install -y libnfnetlink-devel openssl-devel
#安装keepalived
tar zxf ${KEEPALIVED}.tar.gz
if [ $? == 0 ];then
cd ${KEEPALIVED}
./configure
if [ $? == 0 ];then
make
if [ $? == 0 ];then
make install
if [ $? == 0 ];then
echo "Keepalived install successful."
else
echo "make install error"
fi
else
echo "make error."
fi
else
echo "configure error."
fi
else
echo "tar error"
fi