当前位置: 首页 > news >正文

Nginx从入门到实战(八):版本平滑无感知,不停机升级

在这里插入图片描述

一、查看旧版本信息

可以通过nginx -V命令,来查看当前nginx的版本信息,和配置参数。

[root@nb001 sbin]# nginx -V
-bash: nginx: command not found
[root@nb001 sbin]# ./nginx -V
nginx version: nginx/1.20.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --with-http_stub_status_module --with-http_ssl_module

旧版本的sbin目录情况:

[root@nb001 sbin]# ls -lrth
total 14M
-rwxr-xr-x 1 root root 3.8M Nov  1  2021 nginx.old.1
-rwxr-xr-x 1 root root 3.8M Nov  1  2021 nginx.2021年11月3日17:35:42
-rwxr-xr-x 1 root root 5.8M Nov  3  2021 nginx

二、升级

2.1 下载解压最新安装包

点击下载nginx,这里一般是要下载稳定版。如图:
在这里插入图片描述

2.2 上传解压

[root@nb001 softs]# tar -zxvf nginx-1.26.2.tar.gz 
nginx-1.26.2/
nginx-1.26.2/man/
。。。
[root@nb001 nginx-1.26.2]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src

2.3 执行编译

首先执行./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
这个命令的参数和之前版本的保持一致即可

[root@nb001 nginx-1.26.2]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
checking for OS+ Linux 3.10.0-1127.19.1.el7.x86_64 x86_64
checking for C compiler ... found+ using GNU C compiler+ gcc version: 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
checking for gcc -pipe switch ... found
。。。省略。。。
checking for zlib library ... found
creating objs/MakefileConfiguration summary+ using system PCRE library+ using system OpenSSL library+ using system zlib librarynginx path prefix: "/usr/local/nginx"nginx binary file: "/usr/local/nginx/sbin/nginx"nginx modules path: "/usr/local/nginx/modules"nginx configuration prefix: "/usr/local/nginx/conf"nginx configuration file: "/usr/local/nginx/conf/nginx.conf"nginx pid file: "/usr/local/nginx/logs/nginx.pid"nginx error log file: "/usr/local/nginx/logs/error.log"nginx http access log file: "/usr/local/nginx/logs/access.log"nginx http client request body temporary files: "client_body_temp"nginx http proxy temporary files: "proxy_temp"nginx http fastcgi temporary files: "fastcgi_temp"nginx http uwsgi temporary files: "uwsgi_temp"nginx http scgi temporary files: "scgi_temp"[root@nb001 nginx-1.26.2]# 

执行成功后,接着执行make命令:

[root@nb001 nginx-1.26.2]# make
make -f objs/Makefile
make[1]: Entering directory `/data/softs/nginx-1.26.2'
。。。省略。。。
objs/src/http/modules/ngx_http_stub_status_module.o \
objs/ngx_modules.o \
-ldl -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lpthread -lz \
-Wl,-E
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \-e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \-e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \-e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/data/softs/nginx-1.26.2'

执行完make命令之后,可以发现在objs目录下生成了nginx文件

[root@nb001 nginx-1.26.2]# cd objs/
[root@nb001 objs]# ls
autoconf.err  Makefile  nginx  nginx.8  ngx_auto_config.h  ngx_auto_headers.h  ngx_modules.c  ngx_modules.o  src

最后,执行make install,这里install命令都是会看是否存在的,不存在执行安装,存在就不执行对应的复制步骤了。一般可以放心执行。当然如不放心,可以手动复制处理。在此建议备份后(如conf文件,sbin文件,甚至html文件)再执行。

[root@nb001 nginx-1.26.2]# make install
make -f objs/Makefile install
make[1]: Entering directory `/data/softs/nginx-1.26.2'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' \|| mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \|| mv '/usr/local/nginx/sbin/nginx' \'/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' \|| mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types' \|| cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params' \|| cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params \'/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf' \|| cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params' \|| cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params \'/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params' \|| cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params \'/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf' \|| cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' \|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' \|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \|| cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \|| mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/data/softs/nginx-1.26.2'
[root@nb001 nginx-1.26.2]# 

去看sbin目录,和旧版本的sbin目录对比发现:上一个nginx被命名为nginx.old, 并将最新的nginx复制到了sbin下。
且经过查看conf/nginx.conf没有被覆盖。

[root@nb001 sbin]# ls -lrth
total 25M
-rwxr-xr-x 1 root root 3.8M Nov  1  2021 nginx.old.1
-rwxr-xr-x 1 root root 3.8M Nov  1  2021 nginx.202111317:35:42
-rwxr-xr-x 1 root root 5.8M Nov  3  2021 nginx.old
-rwxr-xr-x 1 root root 5.8M Oct  9 09:39 nginx
[root@nb001 sbin]# 

三、校验和最后一步

3.1 查看当前运行的nginx

访问发现,目前还是旧版本。这里访问你的ip随便一个路径就行
在这里插入图片描述

3.2 最后一步升级操作

需要在新版本目录下执行 make upgrade操作,完成进程更新。

[root@nb001 nginx-1.26.2]# make upgrade
/usr/local/nginx/sbin/nginx -t
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /usr/local/nginx/conf/vhost_cvec/ss-prod.conf:2
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /usr/local/nginx/conf/vhost_cvec/us.conf:10
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
sleep 1
test -f /usr/local/nginx/logs/nginx.pid.oldbin
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
[root@nb001 nginx-1.26.2]# 

3.3 再次查看当前运行的nginx

访问发现,已经是新版本啦。
在这里插入图片描述
至此,实现了nginx版本的平滑无感知,不停机升级 , 有需要的小伙伴快去试试吧。

END

相关文章:

Nginx从入门到实战(八):版本平滑无感知,不停机升级

一、查看旧版本信息 可以通过nginx -V命令&#xff0c;来查看当前nginx的版本信息&#xff0c;和配置参数。 [rootnb001 sbin]# nginx -V -bash: nginx: command not found [rootnb001 sbin]# ./nginx -V nginx version: nginx/1.20.1 built by gcc 4.8.5 20150623 (Red Hat …...

jQuery 用户登录页面非空校验与登录测试

文章目录 实战介绍准备工作创建网页导入样式表和jQuery库编写页面代码编写脚本代码创建成功页面浏览网页和测试结束语 实战介绍 大家好&#xff0c;今天我们将一起学习如何使用jQuery来为用户登录页面进行非空校验和登录测试。通过这个实战项目&#xff0c;你将学会如何通过jQ…...

《Linux从小白到高手》综合应用篇:深入理解Linux进程调优

本篇深入介绍Linux进程调优. 1. Linux系统进程类型&#xff1a; Linux的进程可能有成千上万个&#xff1a; ‌新建状态‌&#xff1a;进程刚刚被创建&#xff0c;但尚未运行。 ‌就绪状态‌&#xff1a;进程已经准备好运行&#xff0c;等待CPU分配。 ‌运行状态‌&#xff1…...

Linux安装elasticsearch单机版

下载地址&#xff1a; Download Elasticsearch | Elastic 下载的安装包是elasticsearch-7.12.0-linux-x86_64.tar.gz 解压缩文件 tar -zxvf elasticsearch-7.12.0-linux-x86_64.tar.gz #编辑文件 vim config/elasticsearch.yml# 加入如下配置 # 集群名称&#xff0c;一个…...

el-table表头加红色星标

代码&#xff1a; <el-table-column prop"name" label"姓名" width"auto"><template #header><span style"color: red; margin-right: 4px">*</span><span>姓名</span></template></el…...

2.1 HTML5 - Canvas标签

文章目录 引言Canvas标签概述定义实例&#xff1a;创建画布 理解Canvas坐标系概述实例&#xff1a;获取Canvas坐标 获取Canvas环境上下文概述实例&#xff1a;获取Canvas环境上下文设置渐变色效果 结语 引言 大家好&#xff0c;今天我们要一起探索HTML5中一个非常有趣且强大的…...

T-Box联网安全定义

T-Box&#xff0c;即Telematics BOX&#xff0c;也称远程信息处理控制单元&#xff08;Telematics Control Unit&#xff0c;TCU&#xff09;&#xff0c;是车联网中的重要组成部分。它集成了GPS、外部通信接口、电子处理单元、微控制器、移动通信单元和存储器等功能模块&#…...

7. 整数反转【数学】

文章目录 7. 整数反转解题思路Go代码 7. 整数反转 7. 整数反转 给你一个 32 位的有符号整数 x &#xff0c;返回将 x 中的数字部分反转后的结果。 如果反转后整数超过 32 位的有符号整数的范围 [ − 2 31 , 2 31 − 1 ] [−2^{31}, 2^{31} − 1] [−231,231−1] &#xff0…...

Windows环境NodeJS下载配置安装运行

Windows环境NodeJS下载配置安装运行 &#xff08;1&#xff09;下载 Node.js — Run JavaScript Everywhere 安装文件。 一路傻瓜式安装。 如果安装正常&#xff0c;输入命令可显示版本号&#xff1a; &#xff08;2&#xff09;可以查询nodejs默认的后续依赖安装包位置及缓存…...

石化巡检必备神器,AORO A30防爆手机让“跑冒滴漏”无处藏身!

在石油化工企业生产现场&#xff0c;设备种类繁多&#xff0c;巡检项目错综复杂&#xff0c;任何微小的疏忽都可能引发严重的安全事故。遨游通讯推出了AORO A30防爆手机&#xff0c;精准定位细微故障&#xff0c;在源头上有效控制或消除“跑冒滴漏”等安全隐患。 AORO A30防爆手…...

Smartfusion2开发环境的搭建

Libero软件安装包括libero安装、bibero补丁安装、bibero的license添加和官方ip库的添加等4部分内容组成。具体内容如下所示&#xff1a; 1 Libero软件安装 1、解压LiberoSoC_v11.8的安装包到当前目录&#xff0c;然后运行Libero中的可执行软件进行安装&#xff1b; 图1 双击l…...

使用C++编写一个语音播报时钟(Qt)

要求&#xff1a;当系统时间达到输入的时间时&#xff0c;语音播报对话框中的内容。定时可以取消。qt界面如上图所示。组件如下&#xff1a; countdownEdit作为书写目标时间的line_edit start_btn作为开始和停止的按钮 stop_btn作为取消的按钮 systimelab显示系统时间的lab tex…...

架构师之路-学渣到学霸历程-11

权限管理 我们可以通过一下命令来了解Linux的用户权限&#xff1b; Linux的用户权限真的涉及得非常好&#xff0c;让我们了解一下用户权限的知识吧&#xff1b; let’s go go go~&#xff01; chmod命令&#xff1a; 作用&#xff1a;变更文件或者目录的权限语法&#xff1a…...

Java Mail腾讯企业邮箱或其他邮箱发送邮件失败bug记录

问题出现情况 邮件发送时debug用F8逐步运行可以成功发送邮件&#xff0c;但是用F9或者直接运行程序却发送失败未开启mail的debug模式的报错日志是下面这个&#xff1a;org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is java…...

【大数据】HBase集群断电文件坏块导致集群无法启动处理

hfile文件有坏块 Corrupt文件目录&#xff1a;/hbase/data/… HBase异常&#xff1a;region无法在正常上线&#xff0c;http://master:16010页面看region 一直处于transition状态 wal文件损坏 Corrupt文件目录&#xff1a;/hbase/oldWALs/…或/hbase/WALs/… HBase异常&…...

400行程序写一个实时操作系统(三):Sparrow的学习方法

千里之行始于足下&#xff0c;为了让大家的学习更加事半功倍&#xff0c;笔者将会介绍RTOS的学习方法。 可能很多人拿到一份源码&#xff0c;就想通过各种方式搞懂它&#xff0c;例如抄代码或者读代码。 笔者认为&#xff0c;单纯抄一个实时操作系统是没有任何用处的。比如对…...

为什么人工智能用 Python?

人工智能领域倾向于使用Python&#xff0c;主要归因于Python的多个显著优势&#xff1a; 简洁性与可读性&#xff1a;Python的语法设计简洁明了&#xff0c;代码易于阅读和理解&#xff0c;这对于涉及复杂算法和逻辑的人工智能项目尤为重要。它降低了编程门槛&#xff0c;使得…...

【C++差分数组】P1672何时运输的饲料

本文涉及知识点 C差分数组 C算法&#xff1a;前缀和、前缀乘积、前缀异或的原理、源码及测试用例 包括课程视频 P1672何时运输的饲料 原文比较啰嗦&#xff0c;我简述一下&#xff1a; 第x天运来F1(1<F1<1e6)千克的饲料&#xff0c;第D&#xff08;1<2e3)天还剩F2&…...

Go基础知识:切片

数组 Go 数组的大小是固定的&#xff0c;其长度是其类型的一部分&#xff08;[4]int并且[5]int是不同的、不兼容的类型&#xff09; var a [10]intb : [2]string{"Penn", "Teller"} b : [...]string{"Penn", "Teller"}package maini…...

Redis配置篇 - 指定Redis配置的三种方式,以及Redis配置文件介绍

文章目录 1 指定Redis配置的三种方式1.1 通过命令行参数来指定Redis配置1.2 通过配置文件来指定Redis配置1.3 在服务器运行时更​​改 Redis 配置 2 关于Redis配置文件 1 指定Redis配置的三种方式 1.1 通过命令行参数来指定Redis配置 在redis启动时&#xff0c;可以直接通过命…...

探索scikit-learn的datasets模块:数据集的加载与使用

引言 在机器学习和数据分析领域&#xff0c;数据集的选择和准备是至关重要的一步。scikit-learn库的datasets模块为我们提供了多种内置的数据集&#xff0c;方便我们进行模型训练和测试。这些数据集既有大型的数据集&#xff0c;也有便于教学和初步探索的小型数据集。本文将重…...

手机使用技巧:8 个 Android 锁屏移除工具 [解锁 Android]

有时候&#xff0c;您会被锁定在自己的 Android 设备之外&#xff0c;而且似乎不可能重新进入。 一个例子就是你买了一部二手手机&#xff0c;后来发现无法使用。另一种情况是你忘记了屏幕锁定密码和用于验证密码的 Google 帐户凭据。这种情况很少见&#xff0c;但确实会发生&…...

SSL 协议(HTTPS 协议的关键)

所谓的协议 协议只是一种规则&#xff0c;你不按规则来就无法和目标方进行你的工作 协议说白了只是人定的规则&#xff0c;任何人都可以定协议 我们不需要太了解细节&#xff0c;这些是制定和完善协议的人去做的&#xff0c;我们只需要知道协议的一个大概 一、SSL 协议 1、…...

test_2_27(C指针)

test_2_27 #define _CRT_SECURE_NO_WARNINGS 1#include <stdio.h>使用指针数组来模拟实现二维数组int main() {int* arr[10];//指针数组int arr1[] { 1,2,3,4,5 };int arr2[] { 2,3,4,5,6 };int arr3[] { 3,4,5,6,7 };int* arr[3] {arr1, arr2, arr3};int i 0;for …...

设计模式——门面模式 | 外观模式

哈喽&#xff0c;各位盆友们&#xff01;我是你们亲爱的学徒小z&#xff0c;今天给大家分享的文章是设计模式的——门面模式。 文章目录 定义通用类图1.通用结构2.优点3.缺点 使用场景注意事项1.一个子系统可以有多个门面2.门面不参与子系统内的业务逻辑 定义 定义&#xff1a;…...

FPGA时序分析和约束学习笔记(1、FPGA基本原理)

FPGA时序分析和约束学习笔记-&#xff08;1、FPGA基本原理&#xff09; Field现场Programmable可编程Gate门Array阵列 1、FPGA基本资源组成 可编程逻辑功能块&#xff08;logic elements &#xff0c;缩写LE&#xff09; 片内互联线&#xff08;interconnect&#xff0c;缩写…...

VMware桥接模式无法连接网络

windows下打开控制面板&#xff0c;找到WLAN&#xff0c;记住下面的名称&#xff08;带有VMware的都是虚拟机的网卡&#xff0c;要找到物理主机的网卡&#xff09; 回到VMware&#xff0c;编辑——打开虚拟网络编辑器 桥接选择上面的WLAN下的网络名称&#xff0c;确定即可。&…...

YOLO11改进|卷积篇|引入空间通道重组卷积ScConv

目录 一、【SCConv】卷积1.1【SCConv】卷积介绍1.2【SCConv】核心代码 二、添加【SCConv】卷积2.1STEP12.2STEP22.3STEP32.4STEP4 三、yaml文件与运行3.1yaml文件3.2运行成功截图 一、【SCConv】卷积 1.1【SCConv】卷积介绍 SCConv 模块提供了一种新的视角来看待CNNs的特征提取…...

Java:方法详解

目录 一.什么是方法(method) 二.方法定义 三.方法中实参和形参的关系 四.方法重载 五.递归 一.什么是方法(method) 方法就是一个代码片段&#xff0c;再C语言中我们曾经学过一个类似的方式——函数&#xff0c;他们都是将具有独立功能的代码组织成一个整体&#xff0c;形成…...

Python 三方库下载安装

Python 三方库下载安装 1、在线安装 pip install pandas # 直接安装 python -m pip install pandas # 使用指定Python中的pip进行安装 pip install pandas1.2.3 # 安装指定版本 pip install pandas -i http://pypi.douban.com/simple --trusted-host pypi.…...