Clannaddada

导航

nginx平滑升级

nginx平滑升级

nginx平滑升级

平滑升级:热升级,在不中断服务的情况下升级软件

平滑升级流程:

  1. 获取老版本的编译信息
  2. 获取新版本安装包或者功能包
  3. 配置新版本或功能,配置时加上老版本的编译信息和新版本或功能
  4. 编译,编译后不执行安装操作
  5. 备份老版本程序
  6. 停止老版本程序或进程
  7. 将新版本复制到老版本所在位置替换老版本
  8. 启动新版本

升级示例

1.获取老版本的编译信息

[root@nginx ~]# nginx -V
nginx version: nginx/1.20.2
built by gcc 8.5.0 20210514 (Red Hat 8.5.0-15) (GCC) 
built with OpenSSL 1.1.1k  FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module

2.获取新版本安装包或者功能包

[root@nginx ~]# dnf -y install git        #下载git功能包
[root@nginx ~]# cd /usr/local/src/
[root@nginx src]# wget https://nginx.org/download/nginx-1.22.0.tar.gz
[root@nginx src]# git clone https://gitee.com/wujunze/nginx_module_echo.git
[root@nginx src]# ls
nginx-1.22.0.tar.gz  nginx_module_echo
[root@nginx src]# tar -xf nginx-1.22.0.tar.gz

3.配置新版本或功能,配置时加上老版本的编译信息和新版本或功能

[root@nginx src]# cd nginx-1.22.0/
[root@nginx nginx-1.22.0]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--add-module=../nginx_module_echo

4.编译,编译后不执行安装操作

[root@nginx nginx-1.22.0]# make

#查看版本
[root@nginx nginx-1.22.0]# objs/nginx -v
nginx version: nginx/1.22.0

5.备份老版本程序

[root@nginx nginx-1.22.0]# \cp /usr/local/nginx/sbin/nginx{,-bak}

[root@nginx nginx-1.22.0]# \cp /usr/local/nginx/sbin/nginx{,-bak};pkill nginx;\cp objs/nginx /usr/local/nginx/sbin/;systemctl start nginx

6.停止老版本程序或进程

[root@nginx nginx-1.22.0]# pkill nginx

7.将新版本复制到老版本所在位置替换老版本

[root@nginx nginx-1.22.0]# \cp objs/nginx /usr/local/nginx/sbin/

8.启动新版本

[root@nginx nginx-1.22.0]# systemctl start nginx
[root@nginx nginx-1.22.0]# nginx -v
nginx version: nginx/1.22.0
[root@nginx nginx-1.22.0]# ss -antl
State     Recv-Q    Send-Q       Local Address:Port       Peer Address:Port    Process    
LISTEN    0         128                0.0.0.0:80              0.0.0.0:*                  
LISTEN    0         128                0.0.0.0:22              0.0.0.0:*                  
LISTEN    0         128                   [::]:22                 [::]:*           

posted on 2022-10-12 22:28  linux-ada  阅读(268)  评论(0编辑  收藏  举报