第一步:先安装依赖包 yum install -y libselinux-devel openssl-devel krb5-devel
第二步:在官网下载安装包:https://www.keepalived.org/download.html
第三步:把安装包传上服务器,解压。
第四步:进入解压的文件夹,编译安装 ./configure --prefix=/software/keepalived
//没有权限的话用sudo或者root,但我在make install 时 在/usr/lib/systemd/system下创建文件时sudo还是不够权限,所以只能用root
第五步:make && make install
第六步:cp /software/tools/keepalived-2.2.2/keepalived/etc/init.d/keepalived /etc/init.d
第七步:创建文件夹 mkdir /etc/keepalived
第八步:cp /software/tools/keepalived-2.2.2/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /software/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /software/keepalived/sbin/keepalived /usr/sbin/
第九步:启动keepalived:systemctl start keepalived
查看状态 systemctl status keepalived
如果起不来 检查下网卡名称是否一致,如果不对,请修改一致:
cd /etc/sysconfig/network-scripts/ifcfg-ens160
vi /etc/keepalived/keepalived.conf