平滑公升級nginx

2022-06-15 13:12:13 字數 2475 閱讀 3412

## 先檢視老版本 nginx 的編譯引數,我這裡沒有。

## 進入 nginx 原始碼目錄,按照配置引數 configure make,注意這裡不要 make install

## 備份原來的 nginx 二進位制檔案

[root@centos-linux nginx-1.18.0]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx16.old

## 將剛剛編譯的新的 nginx 二進位制檔案放到 sbin 目錄下

[root@centos-linux nginx-1.18.0]# cp objs/nginx /usr/local/nginx/sbin/

[root@centos-linux nginx-1.18.0]# cd /usr/local/nginx/sbin/

[root@centos-linux sbin]# ls

nginx nginx16.old

## 找到原來的 nginx 程序號,傳送 usr2 命令

[root@centos-linux sbin]# cd ../logs/

## 此時舊的nginx主程序將會把自己的程序檔案改名為.oldbin,然後執行新版 nginx

[root@centos-linux logs]# kill -usr2 `cat /usr/local/nginx/logs/nginx.pid`

## 關閉原來的 nginx 程序

[root@centos-linux logs]# ls

[root@centos-linux logs]# access.log error.log nginx.pid nginx.pid.oldbin

[root@centos-linux logs]# kill -quit `cat nginx.pid.oldbin`

## 檢視新版本的 nginx 資訊

[root@centos-linux nginx-1.18.0]# cd /usr/local/nginx/sbin/

[root@centos-linux sbin]# ./nginx -v

nginx version: nginx/1.18.0

built by gcc 4.8.5 20150623 (red hat 4.8.5-39) (gcc)

built with openssl 1.0.2k-fips 26 jan 2017

tls sni support enabled

configure arguments: --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-http_realip_module

附錄:

安裝 nginx 需要的庫

[root@centos-linux home]# yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

nginx平滑公升級

先來說下我今天要實驗nginx平滑公升級的環境,從nginx.1.8.0公升級到nginx1.9.5 大概的流程 nginx的程序分為master主程序和work工作程序,master程序主要管理事件訊號接受和分發,所有的請求處理都由work程序處理並返回結 果,nginx的平滑重啟或過載配置檔案等...

Nginx平滑公升級

原文 來自nginx官網 如果想要公升級nginx版本 或者在原本版上增加 刪除模組 同時保持服務不間斷,採用如下方式可滿足要求。1.使用新的二進位制檔案替換老的二進位制檔案,這需要注意的是nginx原始碼在執行make編譯後,不要直接make install,否則可能會覆蓋其他配置檔案,命令如下 ...

Nginx平滑公升級

有時,我們需要對我們的伺服器進行公升級更高版本。此時,如果我們強行將伺服器停止然後直接公升級,這樣原來在伺服器上執行著的程序就會被影響。如何解決這個問題呢?可以通過平滑公升級的方式來解決。平滑公升級時,不會停掉在執行著的程序,這些程序會繼續處理請求,但不會再接受新請求,在這些老程序在處理完還在處理的...