原理
1.创建两个虚拟机:192.168.88.3(设为master),192.168.88.4(设为backup)
2.在两个虚拟机上都安装nginx,jdk,keepalived
安装keepalived:
yum install keepalived 安装keepalived yum:联网安装
rpm -q -a keepalived 检查是否安装keepalived ps -ef | grep keepalived
3.修改/etc/keepalied/下的keepalived.conf文件。
4.把nginx_check.sh拖到/usr/local/src/nginx_check.sh下,与上图路径一致。
5.开启两个虚拟机的nginx和keeplived
命令:
./nginx
systemctl start keepalived.service
6.测试访问虚拟的端口号。
7.让master宕机
./nginx -s stop
systemctl stop keepalived.service
8. 再次访问,与上一次对比。