环境配置
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注释