文章目录

一、部署总览+常用命令
1. 部署总览

ip地址

端口

软件

192.168.159.140

80

nginx

192.168.159.141

80

nginx

192.168.159.140


keepalived

192.168.159.141


keepalived

192.168.159.150

80

vip

2. 常用命令
  • keepalived
service
service
service
  • nginx
    指定配置文件启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

指定配置文件重启

/usr/local/nginx/sbin/nginx -s reload -c /usr/local/nginx/conf/nginx.conf
二、软件安装配置
2.1. 安装keepalived


2.2. 安装nginx


2.3. 配置静态文件

编辑nginx->index.html文件

vim

nginx高可用方案:keepalived+nginx vip 动态位移_常用命令


nginx高可用方案:keepalived+nginx vip 动态位移_html_02

三、测试
3.1. 启动nginx

140和141依次启动nginx

cd
3.2. 验证

nginx高可用方案:keepalived+nginx vip 动态位移_nginx_03


nginx高可用方案:keepalived+nginx vip 动态位移_html_04


nginx高可用方案:keepalived+nginx vip 动态位移_nginx_05

四、vip动态位移测试
4.1. 140验证
ip

nginx高可用方案:keepalived+nginx vip 动态位移_html_06

4.2. 141验证
ip

nginx高可用方案:keepalived+nginx vip 动态位移_常用命令_07

4.3. 140停止kp服务
ip

nginx高可用方案:keepalived+nginx vip 动态位移_nginx_08

4.4. 141 验证

vip飘移到了141节点

ip

nginx高可用方案:keepalived+nginx vip 动态位移_常用命令_09

4.5. 140 重新启动kp服务

重新启动

service

vip飘移到了140节点

ip

nginx高可用方案:keepalived+nginx vip 动态位移_nginx_10