实验环境:
master | 192.168.76.3 | 提供负载均衡 |
backup | 192.168.76.4 | 提供负载均衡 |
LVS-DR-vip | 192.168.76.123 | 网站的VIP地址 |
web1 | 192.168.76.5 | 提供web服务 |
web2 | 192.168.76.6 | 提供web服务 |
1.先配置web1和web2服务
web2:
web1:
2.配置master
安装nginx
配置nginx反向代理:vim /etc/nginx/nginx.conf
安装keepalived: yum install keepalived -y
配置keepalived:vim /etc/keepalived/keepalived.conf
backup步骤和master一样
keepalived文件的区别:
测试,用浏览器访问192.168.76.123,然后再断掉master网络连接,再去访问。
master和backup编写nginx健康检测脚本: /etc/keepalived/ch_ng.sh
给脚本加执行权限,然后将keepalived的注释部分去掉#。
master停掉nginx服务,查看ip a ,看一下vip是否跳到backup中