• Nginx平滑升级


    Nginx/1.5.7 升级到 nginx/1.10.2

    当需要将正在运行的Nginx升级、添加或删除服务模块时,可以在不中断服务的情况下,更新升级,重新编译Nginx替换旧版本。
    [root@ ~]# /usr/local/nginx/sbin/nginx  -V
    nginx version: nginx/1.5.7
    built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 
    TLS SNI support enabled
    configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_auth_request_module --add-module=/data/src/nginx-upstream-fair-master
    
    编译 nginx/1.10.2,具体的编译选项根据业务需要来,这里只是做版本升级。
    [root@ src]# tar xf nginx-1.10.2.tar.gz
    [root@ src]# cd nginx-1.10.2
    [root@ src]# ./configure  --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_auth_request_module --add-module=/data/src/nginx-upstream-fair-master 
    [root@ src]# make && make install
    
    编译完后,旧版的二进制文件已经被替换为新版的。这时让新的进程也启动:
    [root@ nginx-1.10.2]# kill -USR2 `cat /usr/local/nginx/logs/nginx.pid` && sleep 1s
    

    此时,系统中存在新旧两类nginx进程

    [root@ nginx-1.10.2]#lsof -i:80
    COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    nginx   16717 root    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   16718  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   16719  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   16720  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   16721  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   19567 root    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   19568  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   19569  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   19570  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   19571  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    
    旧版的nginxpid文件会被命名为nginx.pid.oldbin,这时候从容关闭旧的nginx 子进程,再关闭旧ningx主进程
    [root@ nginx-1.10.2]# kill -WINCH `cat /usr/local/nginx/logs/nginx.pid.oldbin`          #关闭旧的子进程                 
    [root@ nginx-1.10.2]# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`              #关闭旧ningx主进程
    [root@ nginx-1.10.2]# lsof -i:80
    COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    nginx   19567 root    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   19568  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   19569  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   19570  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    nginx   19571  www    9u  IPv4  30087      0t0  TCP *:http (LISTEN)
    
    回滚

    在执行关闭旧子进程前可以停留几分钟,或者在执行关闭旧子进程后停留几分钟,观察新进程是否正常。如果有异常可以进行回滚

    [root@ nginx-1.10.2]# kill -HUP `cat /usr/local/nginx/logs/nginx.pid.oldbin`  #重新启动旧子进程
    [root@ nginx-1.10.2]# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid`           #退出新ningx主进程
    
  • 相关阅读:
    [搬运] Tina R329 swupdate OTA 步骤
    摄像头 ISP 调试的经验之谈(以全志 AW hawkview 为例)
    2021 年了 在 WSL2 中使用 adb 、fastboot 的等命令
    wsl2 编译 linux openwrt 项目的时候,经常会出现 bash: -c: line 0: syntax error near unexpected token `('
    sipeed v833 硬件验证以及开发记录(2021年5月18日)
    Allwinner & Arm 中国 & Sipeed 开源硬件 R329 SDK 上手编译与烧录!
    把 R329 改到 ext4 sdcard 启动变成 Read-Only 系统,导致没有文件修改权限后如何修复。
    linux kernel version magic 不一致导致的模块 加载 (insmod) 不上
    剑指 Offer 17. 打印从1到最大的n位数
    剑指 Offer 16. 数值的整数次方
  • 原文地址:https://www.cnblogs.com/wshenjin/p/7086376.html
Copyright © 2020-2023  润新知