参考 keepalived 编译安装https://www.jianshu.com/p/fdc0a788f55a/
参考 https://blog.csdn.net/weixin_44285972/article/details/122624848
yum install -y net-tools psmisc
【修改keepalived 配置文件看到】
vim /etc/keepalived/keepalived.conf
!Configuration File for keepalived
global_defs {
router_id nginx_server_1
}
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 90
mcast_src_ip 192.168.129.92
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.129.90/24 // 虚拟IP
}
}
【把keepalived设置成系统服务】
vim /lib/systemd/system/keepalived.service
[Unit]
Description=LVS and VRRP High Availability Monitor
After=syslog.target network-online.target
[Service]
Type=forking
PIDFile=/var/run/keepalived.pid
KillMode=process
EnvironmentFile=-/etc/sysconfig/keepalived
ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
~