1. 下载安装包然后解压
1解压
tar -zxvf keepalived-2.2.2.tar.gz
cd /opt/keepalived-2.2.2
./configure --prefix=/usr/local/keepalived
有时候可能会报这个错误信息,此时只需要安装 libnl/libnl-3
依赖即可,输入 yum -y install libnl libnl-deve
*** WARNING - this build will not support IPVS with IPv6. Please install libnl/libnl-3 dev libraries to support IPv6 with IPVS.
检查生成了 Makefile
文件后可以输入以下命令进行安装
make && make install
Keepalived 并不像 Nginx 一样提供关闭指令,要关闭 Keepalived,需要杀死对应进程,ps -ef|grep keepalived 查看进程ID,kill -9 进程ID 关闭 Keepalived。
这样做很麻烦,所以可以将 Keepalived 作为服务注册到 Linux 系统,具体操作:
将解压后的 keepalived-2.0.18/keepalived/etc/init.d/keepalived 文件和 keepalived-2.0.18/keepalived/etc/sysconfig 文件拷贝到当期系统中: