方法1:使用yum安装
# yum -y install keepalived # chkconfig keepalived on
方法2:源码编译安装
安装约定
keepalived源码路径:/usr/local/src
keepalived配置文件路径:/etc/keepalived/keepalived.conf
下载源码
# cd /usr/local/src # wget http://www.keepalived.org/software/keepalived-1.2.12.tar.gz
安装gcc、make等
# yum -y install gcc make
安装编译keepalived所需库
# yum -y install openssl openssl-devel
编译安装keepalived
# tar zxvf keepalived-1.2.12.tar.gz # cd keepalived-1.2.12 # ./configure --prefix=/usr/local/keepalived
配置keepalived服务
# cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/ # cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/ # mkdir /etc/keepalived # cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/ # cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
启动keepalived
# service keepalived start
配置keepalived开机启动
# chkconfig keepalived on