1、下载tar包
https://www.keepalived.org/download.html
2、编译安装
# 解压
tar -xvf keepalived-1.4.5.tar.gz -C /opt/keepalivedll
# 安装依赖库
yum install -y gcc openssl-devel popt-devel -y
# 编译,-with-init=SYSV 编译生成启动脚本
./configure --prefix=/opt/keepalived -with-init=SYSV
# 安装
make && make install
3、运行前准备
ln -s /opt/keepalived/etc/keepalived /etc/
ln -s /opt/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
ln -s /opt/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
ln -s /opt/keepalived/sbin/ /sbin/
chmod +x /opt/keepalived/etc/rc.d/init.d/keepalived
4、修改配置文件
vim /etc/keepalived/keepalived.conf
5、启动
# 使用systemctl 管理需要将配置添加一个/etc/keepalived/keepalived.conf配置文件,可以执行
# ln -s /opt/keepalived/etc/keepalived /etc/
systemctl enable keepalived
systemctl start keepalived