溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

詳解nginx平滑升級的過程

發布時間:2020-09-06 20:56:15 來源:腳本之家 閱讀:153 作者:譚普利特 欄目:服務器

1、開始之前首先查看當前的使用版本以及編譯時的參數:

[root@www ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.12.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

將編譯參數復制出來,編譯新版本的時候會用到。

2、下載新版本:http://nginx.org/en/download.html

cd nginx-1.14.0

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

make

3、執行完成之后,不需要make install ,備份原來的二進制啟動文件,然后將新版的啟動文件拷貝過去

mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
[root@www nginx-1.14.0]# cp objs/nginx /usr/local/nginx/sbin/nginx

4、測試一下復制過來的文件是否生效:

[root@www nginx-1.14.0]# /usr/local/nginx/sbin/nginx -t
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

5、發送USR2信號給nginx master 進程(nginx服務接收到USR2信號后,首先會將舊的nginx.pid文件添加后綴.oldbin,變為nginx.pid.oldbin,然后執行新版本的二進制文件啟動服務,如果新的服務啟動成功,系統中將有新舊兩個Nginx服務共同提供web服務)

kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`


[root@www nginx-1.14.0]# ps -ef | grep nginx 
root   22644   1 0 23:30 ?    00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
www   22648 22644 0 23:30 ?    00:00:00 nginx: worker process   
root   25784 22644 0 23:47 ?    00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
www   25789 25784 0 23:47 ?    00:00:00 nginx: worker process  

6、通過發送WINCH信號(平緩停止worker process)和QUIT信號(平緩停止Nginx服務)停止舊的Nginx服務進程

kill -WINCH `cat /usr/local/nginx/logs/nginx.pid.oldbin` 
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`  

7、升級完成,最后看一下nginx版本:

/usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.14.0

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持億速云。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女