环境配置
master主机192.168.199.149,虚拟IP192.168.199.148
back备机192.168.199.150
真实服务器1 192.168.199.155
真实服务器2 192.168.199.156
关闭防火墙和selinux
master配置(149)
添加虚拟IP
ip addr add 192.168.199.148/24 dev ens33
下载keepalived
yum install keepalived -y
配置文件
vim /etc/keepalived/keepalived.conf

备机配置(155,156)
下载keepalived
yum install keepalived -y
配置文件
vim /etc/keepalived/keepalived.conf
配置文件与主机类似,只需要修改
state BACKUP
priority 90
真实服务器配置
yum install nginx


配置回环网卡

测试
在浏览器中输入虚拟ip


问题
当出现负载均衡效果不明显时:(默认会在155,156页面上跳转)
把keepalived配置文件的presistence_timeout 1注释



![使用ChatGPT高效完成简历制作[中篇3]-有爱AI实战教程(十)](https://img-blog.csdnimg.cn/direct/a82dd1b63b2448149423e8b2ef4c12e1.png)




![[AIGC] 在Spring Boot中指定请求体格式](https://img-blog.csdnimg.cn/direct/cd575d2000a34da69f729f18eddfa1ff.png)











