Keepalived安装
环境:两台nginx服务器
- 下载Keepalived安装包
curl https://www.keepalived.org/software/keepalived-2.2.7.tar.gz -o keepalived-2.2.7.tar.gz -k
- 解压到跟nginx安装包同一个目录下
tar -zxvf keepalived-2.2.7.tar.gz
3. 配置Keepalived,进入keepalived-2.2.7目录下使用以下命令
./configure \
--prefix=/usr/local/keepalived \
--sysconf=/etc
# prefix 安装目录
# sysconf 核心配置文件
4. 编译和安装
make
make install
- 启动
cd /usr/local/keepalived/
ll
cd sbin/
./keepalived
Keepalived核心配置文件
- 查看IP地址
- 进入etc/keepalived目录下配置Keepalived.conf文件
cd /etc/keepalived
vim keepalived.conf
修改以下配置
3. 启动keepalived,再查看IP地址,可以发现多了一个IP地址,也就是VIP