Ubuntu安装keepalived

安装准备工作

系统版本:ubuntu 20.04

安装依赖模块:

sudo apt-get install libssl-dev 
sudo apt-get install openssl 
sudo apt-get install libpopt-dev 
sudo apt-get install libnl-3-dev
sudo apt-get install libnl-genl-3-dev

Ubuntu安装keepalived_第1张图片

下载和安装(方法一)

下载文件

去Keepalived for Linux查看最新的版本,我看的时候是2.2.2版本

wget https://www.keepalived.org/software/keepalived-2.2.2.tar.gz

Ubuntu安装keepalived_第2张图片

解压文件

tar xzf keepalived-2.2.2.tar.gz

进入解压后的目录

cd keepalived-2.2.2
./configure --prefix=/usr/wjp/keepalived/

Ubuntu安装keepalived_第3张图片

检查通过:

Ubuntu安装keepalived_第4张图片

make && make install

Ubuntu安装keepalived_第5张图片

完成

大功告成,程序被安装在了 /usr/wjp/keepalived 目录下

Ubuntu安装keepalived_第6张图片

下载和安装(方法二)

直接使用apt安装,与方法一的效果一致,但安装在/etc/目录下:

sudo apt-get install keepalived

Ubuntu安装keepalived_第7张图片

检查是否安装好

keepalived -v

Ubuntu安装keepalived_第8张图片

 

启动停止控制

sudo service keepalived [start | stop | reload | restart ]

检查是否启动

ps -ef | grep keepalived

设置随系统自启动

编辑 /etc/rc.local文件

sudo vim /etc/rc.local

在其中添加上:

#!/bin/sh -e
service keepalived start &

exit 0

注意:

1. 对于服务类,一定要以 & 结尾,表示不要等待运行结果

2. 文档最后一定要以 exit 0结尾,表示文档结束

 

 

参考文献

Keepalived的安装与启动 | 精彩每一天 (hangdaowangluo.com)

Nginx+keepalived双机热备(主从模式)_宋发元-CSDN博客

你可能感兴趣的:(Linux,ubuntu,负载均衡)