平滑升级旧版nginx,使其支持健康检测模组

nginx是部署在华为欧拉的docker容器中,版本是2203sp1.x86_64

查看旧版nginx的版本与编译配置信息:

nginx -V

nginx version: nginx/1.14.1
built by gcc 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)
built with OpenSSL 1.1.1g FIPS 21 Apr 2020 (running with OpenSSL 1.1.1k FIPS 25 Mar 2021)
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-pa/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy —path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-pats/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module -odule=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzittp_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_stathttp_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-streamh-debug --with-cc-opt=‘-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-cs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection --with-ld-opt=’-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E’

根据nginx信息找到第三方模组所在文件夹:--modules-path=/usr/lib64/nginx/modules

进入文件夹:

cd /usr/lib64/nginx/modules

下载健康检测模组压缩包并解压:

wget https://codeload.github.com/yaoweibin/nginx_upstream_check_module/zip/masterunzip master # 解压到当前目录rm -rf master # 删除压缩包

安装patch工具:

yum install patch -y

在nginx中文网找到最新稳定版本nginx-1.24.0.tar.gz,下载到opt目录,并解压:

tar -xzvf nginx-1.24.0.tar.gzcd nginx-1.24.0 # 进入已解压的目录

在已解压的目录内打上健康检测模组补丁(补丁版本不能高于nginx的版本,越接近越好):

patch -p1 < /usr/lib64/nginx/modules/nginx_upstream_check_module-master/check_1.20.1+.patch

打印出下面的信息,说明补丁执行成功:
patching file src/http/modules/ngx_http_upstream_hash_module.c
patching file src/http/modules/ngx_http_upstream_ip_hash_module.c
patching file src/http/modules/ngx_http_upstream_least_conn_module.c
patching file src/http/ngx_http_upstream_round_robin.c
patching file src/http/ngx_http_upstream_round_robin.h

执行./configure命令重新编译nginx(参考旧版本nginx的编译配置信息,可直接复制过来,结尾增加--add-module=/usr/lib64/nginx/modules/nginx_uule-master命令即可):

./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/vproxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --wimodule --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4tp_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_modtub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-strh-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-pgrecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables tection -fcf-protection' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' --add-module=/usr/lib64/nginx/modules/nginx_uule-master

编译异常处理,一般都是缺依赖库,依赖库安装完成后重新编译即可:

  1. ERROR ./configure: error: the invalid value in --with-ld-opt="-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E"
yum -y install redhat-rpm-config.noarch
  1. ERROR ./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module
    option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre= option.`
yum install pcre pcre-devel
  1. ERROR ./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library
    into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl= option.`
yum -y install openssl openssl-devel
  1. ERROR ./configure: error: the HTTP XSLT module requires the libxml2/libxslt libraries. You can either do not enable the module or install the libraries.`
yum install -y libxml2-devel.x86_64yum install -y libxslt-devel.x86_64
  1. ERROR ./configure: error: the HTTP image filter module requires the GD library. You can either do not enable the module or install the libraries.`
yum install -y gd-devel.x86_64
  1. ERROR ./configure: error: perl module ExtUtils::Embed is required
yum -y install perl-devel perl-ExtUtils-Embed

出现下面的打印,说明编译成功:

creating objs/Makefile

Configuration summary

  • using system PCRE2 library
  • using system OpenSSL library
  • using system zlib library

nginx path prefix: “/usr/share/nginx”
nginx binary file: “/usr/sbin/nginx”
nginx modules path: “/usr/lib64/nginx/modules”
nginx configuration prefix: “/etc/nginx”
nginx configuration file: “/etc/nginx/nginx.conf”
nginx pid file: “/run/nginx.pid”
nginx error log file: “/var/log/nginx/error.log”
nginx http access log file: “/var/log/nginx/access.log”
nginx http client request body temporary files: “/var/lib/nginx/tmp/client_body”
nginx http proxy temporary files: “/var/lib/nginx/tmp/proxy”
nginx http fastcgi temporary files: “/var/lib/nginx/tmp/fastcgi”
nginx http uwsgi temporary files: “/var/lib/nginx/tmp/uwsgi”
nginx http scgi temporary files: “/var/lib/nginx/tmp/scgi”

编译成功后,执行make命令生成nginx二进制程序:

make

出现下面的打印,说明生成二进制程序成功:

-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E
-shared
sed -e “s|%%PREFIX%%|/usr/share/nginx|”
-e “s|%%PID_PATH%%|/run/nginx.pid|”
-e “s|%%CONF_PATH%%|/etc/nginx/nginx.conf|”
-e “s|%%ERROR_LOG_PATH%%|/var/log/nginx/error.log|”
< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory ‘/opt/nginx-1.24.0’

备份旧的二进制程序(旧程序的路径可通过编译配置信息的--sbin-path获知):

mv /usr/sbin/nginx /usr/sbin/nginx.bak

将新生成的二进制程序替换旧的(新生成的二进制程序在objs目录中):

cp /opt/nginx-1.24.0/objs/nginx /usr/sbin/nginx

查看nginx版本信息,执行nginx自检命令,查看是否升级成功:

nginx -V # 查看版本
nginx -t # 自检

打印下面的信息说明升级成功:

nginx version: nginx/1.24.0

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

配置健康检测参数到原来的nginx配置文件中:

upstream backend_server_crmp {# interval 检测的间隔时间 毫秒# rise 连接成功多少次为可用# fall 连接失败多少次为不可用# timeout 连接超时时间 毫秒# type 检测连接所用的协议类型check interval=5000 rise=2 fall=3 timeout=1000 type=tcp;......}

配置路由,可通过浏览器查看监控检测界面:

location /status {check_status;}

配置成功后,可访问路由查看监控检测页面如下:
在这里插入图片描述

nginx升级支持健康检测模组到这里就完成了

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/689502.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

前后图片对比控件使用

在build.gradle中添加依赖&#xff1a; implementation com.github.pavel163:BifacialView:1.4.1 在布局文件中&#xff1a; <com.ebr163.bifacialview.view.BifacialViewandroid:id"id/bv_before_after"android:layout_width"match_parent"android:la…

LNMP搭建discuz论坛

discuz论坛是一种网络论坛软件&#xff0c;也称bbs&#xff0c;它是一种用于在互联网上建立论坛社区的程序系统。只哟中功能强大的论坛软件&#xff0c;可以帮助用户建立一个专业、完善的论坛社区&#xff0c;并且可以实现多种功能&#xff0c;如搭建用户注册、登录、查看主题、…

任务处理 - 华为OD统一考试(C卷)

OD统一考试&#xff08;C卷&#xff09; 分值&#xff1a; 200分 题解&#xff1a; Java / Python / C 题目描述 在某个项目中有多个任务(用tasks数组表示)需要您进行处理&#xff0c;其中tasks[i][si,ei], 你可以在si < day < ei 中的任意一天处理该任务&#xff0c;请…

代码随想录day25--回溯的应用4

LeetCode491.非递减子序列 题目描述&#xff1a; 给你一个整数数组 nums &#xff0c;找出并返回所有该数组中不同的递增子序列&#xff0c;递增子序列中 至少有两个元素 。你可以按 任意顺序 返回答案。 数组中可能含有重复元素&#xff0c;如出现两个整数相等&#xff0c;…

【目标跟踪】提供一种简单跟踪测距方法(c++)

文章目录 一、前言二、c代码2.1、Tracking2.2、KalmanTracking2.3、Hungarian2.4、TrackingInfo 三、调用示例四、结果 一、前言 在许多目标检测应用场景中&#xff0c;完完全全依赖目标检测对下游是很难做出有效判断&#xff0c;如漏检。检测后都会加入跟踪进行一些判断或者说…

中科星图——Landsat8_C2_ST数据集是经大气校正的地表温度数据

数据名称&#xff1a; Landsat8_C2_ST 数据来源&#xff1a; USGS 时空范围&#xff1a; 2020年1月-2023年3月 空间范围&#xff1a; 全国 数据简介&#xff1a; Landsat8_C2_ST数据集是经大气校正的地表温度数据&#xff0c;属于Collection2的二级数据产品&#xff0…

nginx 日志改为json格式

nginx 日志改为json格式 场景描述 正常使用nginx时&#xff0c;使用默认的日志输出格式&#xff0c;对于后续日志接入其他第三方日志收集、清洗环节&#xff0c;因分隔符问题可能不是很友好。 xxxx - - [19/Feb/2024:11:16:48 0800] "GET /time_feed HTTP/1.1" 20…

虚拟和现实的界限不存在了吗

Sora是美国人工智能公司OpenAI最新发布的“文生视频”大模型。与之前的模型相比&#xff0c;Sora能够一次性生成长达一分钟的高清视频&#xff0c;这是目前业内主流的数秒钟版本所无法比拟的。Sora的发布在市场上引起了极大的关注&#xff0c;并被认为是人工智能领域的一次重大…

【Java EE初阶十三】网络初识

1. 网络发展史 网络发展的几个主要时期&#xff1a; 单机时代->局域网时代->广域网时代->移动互联网时代 随着时代的发展&#xff0c;越来越需要计算机之间互相通信&#xff0c;共享软件和数据&#xff0c;即以多个计算机协同工作来完成 业务&#xff0c;就有了网络互…

行人重识别

&#xfeff;在人的感知系统所获得的信息中&#xff0c;视觉信息大约占到80%&#xff5e;85%。行人重识别&#xff08;person re-identification&#xff09;是近几年智能视频分析领域兴起的一项新技术&#xff0c;属于在复杂视频环境下的图像处理和分析范畴&#xff0c;是许多…

300分钟吃透分布式缓存-02讲:如何根据业务来选择缓存模式和组件?

缓存读写模式 如下图&#xff0c;业务系统读写缓存有 3 种模式&#xff1a; & Cache Aside&#xff08;旁路缓存&#xff09; & Read/Write Through&#xff08;读写穿透&#xff09; & Write Behind Caching&#xff08;异步缓存写入&#xff09; Cache Asid…

redis 值中文显示乱码

问题&#xff1a; 解决办法&#xff1a; exit退出 进入时添加 --raw参数

【软件设计师】程序猿需掌握的技能——数据流图

作为一个程序员&#xff0c;不仅要具备高水平的程序编码能力&#xff0c;还要是熟练掌握软件设计的方法和技术&#xff0c;具有一定的软件设计能力&#xff0c;一般包括软件分析设计图&#xff08;常见的有数据流图&#xff0c;程序流程图&#xff0c;系统流程图&#xff0c;E-…

每日一练:LeeCode-501、二叉搜索树中的众数【二叉搜索树+pre辅助节点+DFS】

本文是力扣LeeCode-LeeCode-501、二叉搜索树中的众数【二叉搜索树pre辅助节点DFS】 学习与理解过程&#xff0c;本文仅做学习之用&#xff0c;对本题感兴趣的小伙伴可以出门左拐LeeCode。 给你一个含重复值的二叉搜索树&#xff08;BST&#xff09;的根节点 root &#xff0c;…

个性签名大全

只许一生浮世清欢愿我以孤独作为铠甲&#xff0c;自此不再受伤愿我是阳光&#xff0c;明媚而不忧伤我不敢太勇敢太执着太骄傲&#xff0c;我怕失去开始你是我的天使&#xff0c;最后你是我的唯一姐的霸气&#xff0c;无人能比&#xff0c;哥的傲气&#xff0c;无人能朋唯有万事…

ASUS华硕枪神8笔记本电脑G614JIR,G814JVR,G634JYR,G834JZR工厂模式出厂Windows11系统 带重置还原功能

适用ROG枪神8系列笔记本型号&#xff1a; G614JIR、G614JVR、G634JYR、G634JZR G814JIR、G814JVR、G834JYR、G834JZR 链接&#xff1a;https://pan.baidu.com/s/1tYZt6XFNC2d6YmwTbtFN7A?pwd3kp8 提取码&#xff1a;3kp8 带有ASUS RECOVERY恢复功能、自带所有驱动、出厂主…

PyCharm - Run Debug 程序安全执行步骤

PyCharm - Run & Debug 程序安全执行步骤 1. Run2. DebugReferences 1. Run right click -> Run ‘simulation_data_gene…’ or Ctrl Shift F10 2. Debug right click -> Debug ‘simulation_data_gene…’ 在一个 PyCharm 工程下&#xff0c;存在多个 Pytho…

3个密码学相关的问题

一、离散对数问题&#xff08;Discrete Logarithm Problem, DLP&#xff09; 问题描述&#xff1a;给定 有限阿贝尓群 G中的2个元素a和b&#xff0c;找出最小的正整数x满足&#xff1a;b a ^^ x &#xff08;或者证明这样的x不存在&#xff09;。 二、阶数问题&#xff08;O…

【PyQt】13-对话框

文章目录 前言一、知识储备二、详细展开2.1 通用对话框-QDialog2.1 消息类型对话框-QMessageBox运行结果 2.2 输入对话框 QInputDilog运行结果 2.3 字体对话框-QFontDialog运行结果 2.4 颜色对话框运行结果 2.5 文件对话框运行结果 总结 前言 1、四种形式的对话框。 2、警告框…

深入理解 Vue3 中的 setup 函数

&#x1f497;&#x1f497;&#x1f497;欢迎来到我的博客&#xff0c;你将找到有关如何使用技术解决问题的文章&#xff0c;也会找到某个技术的学习路线。无论你是何种职业&#xff0c;我都希望我的博客对你有所帮助。最后不要忘记订阅我的博客以获取最新文章&#xff0c;也欢…