zoukankan      html  css  js  c++  java
  • nginx 配置轮询做分流 实现蓝绿部署

    项目开发中经常遇到发版问题,而且很多线上环境是不能再工作时间停止的,如果能做到蓝绿部署应该可以解决这个问题.

    这个demo只作为一个引导后续有机会了在更新最佳实践。

    准备工作:

    step1:下载tomcat 和 nginx包 

    step2:将tomcat备份一个,修改 端口号 

                tomcat A  --- port:3333

                tomcat B  --- port:   4444

    step3: 写两份index.html 分别部署到tomcat的 webappsROOT目录下

               tomcat A   ---  hello word 111

               tomcat B   ---   hello word 222

    step4:修改nginx的配置项 配置轮训策略

              

        upstream linuxidc { 
            server localhost:4444 weight=4; ##down 
    server localhost:
    5555 weight=10; } server { listen 3333; server_name localhost; location / { proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://linuxidc; } }

       启动nginx就可以了 

    step 5:

        如果你的tomcat A 在发版 可以把nginx代理到这个服务器的配置注释掉 这样就没有流量进去了 此时可以自由发版,当发版成功后对tomcat B 做相同的动作 等待两个系统稳定后再切回到之前的权重即可。

    学而时习之不亦悦乎。
  • 相关阅读:
    jsp第六周作业
    jsp第四次作业
    JSP第二次作业 2021 0310
    软件测试作业 NO.1
    北航软工优秀作业汇总
    Alpha阶段评审结果和意见反馈
    转会候选人名单
    人员转会流程
    关于团队项目阶段目标的说明
    2021年软工-热身阅读作业
  • 原文地址:https://www.cnblogs.com/xianZJ/p/11652274.html
Copyright © 2011-2022 走看看