实验环境
准备2台设备
设备1 192.168.217.11 nginx +keepalived
设备2 192.168.217.12 nginx +keepalived
虚拟ip 192.168.217.3
设备1、2 安装nginx keepalived
(此处设备已安装nginx)
我们在此基础上直接利用yum安装keepalived
更新网络yum源
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]# wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
--2022-06-11 17:56:31-- http://mirrors.aliyun.com/repo/epel-7.repo
安装keepalived
[root@localhost ~]# yum -y install keepalived.x86_64
启动nginx
[root@localhost ~]# cd /usr/src/nginx-1.12.2/
[root@localhost nginx-1.12.2]# killall -9 nginx
[root@localhost nginx-1.12.2]# nginx
修改keepalived配置文件
[root@localhost nginx-1.12.2]# vim /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {