成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

Nginx版本的平滑升級與回滾怎么實現(xiàn)

本篇內(nèi)容介紹了“Nginx版本的平滑升級與回滾怎么實現(xiàn)”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!

創(chuàng)新互聯(lián)建站從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目網(wǎng)站制作、做網(wǎng)站網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元個舊做網(wǎng)站,已為上家服務(wù),為個舊各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792

1、環(huán)境介紹

今天準備的兩個nginx版本如下:

[root@nginx ~]# cd /download/nginx/ [root@nginx nginx]# ll total 1952 -rw-r--r-- 1 root root  981687 Oct 17  2017 nginx-1.12.2.tar.gz -rw-r--r-- 1 root root 1015384 Dec  4 09:58 nginx-1.14.2.tar.gz

2、編譯安裝新舊版本

編譯安裝nginx-1.12.2

[root@nginx nginx]# tar zxf nginx-1.12.2.tar.gz  [root@nginx nginx]# cd nginx-1.12.2 [root@nginx nginx-1.12.2]# ./configure --prefix=/usr/local/nginx-1.12.2 [root@nginx nginx-1.12.2]# echo $? 0 [root@nginx nginx-1.12.2]# make && make install [root@nginx nginx-1.12.2]# echo $? 0 [root@nginx nginx-1.12.2]# ll /usr/local/nginx-1.12.2/ total 0 drwxr-xr-x 2 root root 333 Mar  1 09:01 conf drwxr-xr-x 2 root root  40 Mar  1 09:01 html drwxr-xr-x 2 root root   6 Mar  1 09:01 logs drwxr-xr-x 2 root root  19 Mar  1 09:01 sbin

編譯安裝nginx-1.14.2

[root@nginx ~]# cd /download/nginx/ [root@nginx nginx]# tar zxf nginx-1.14.2.tar.gz  [root@nginx nginx]# cd nginx-1.14.2 [root@nginx nginx-1.14.2]# ./configure --prefix=/usr/local/nginx-1.14.2 [root@nginx nginx-1.14.2]# echo $? 0 [root@nginx nginx-1.14.2]# make && make install [root@nginx nginx-1.14.2]# echo $? 0 [root@nginx nginx-1.14.2]# ls -l /usr/local/nginx-1.14.2/ total 0 drwxr-xr-x 2 root root 333 Mar  1 09:03 conf drwxr-xr-x 2 root root  40 Mar  1 09:03 html drwxr-xr-x 2 root root   6 Mar  1 09:03 logs drwxr-xr-x 2 root root  19 Mar  1 09:03 sbin

到這里,兩個版本的nginx軟件已經(jīng)部署完成。

3、啟動舊版本nginx

[root@nginx ~]# /usr/local/nginx-1.12.2/sbin/nginx -t nginx: the configuration file /usr/local/nginx-1.12.2/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx-1.12.2/conf/nginx.conf test is successful [root@nginx ~]# /usr/local/nginx-1.12.2/sbin/nginx [root@nginx ~]# ps -ef|grep nginx root       6324      1  0 09:06 ?        00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx nobody     6325   6324  0 09:06 ?        00:00:00 nginx: worker process root       6327   1244  0 09:06 pts/0    00:00:00 grep --color=auto nginx [root@nginx ~]# lsof -i :80 COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME nginx   6324   root    6u  IPv4  26324      0t0  TCP *:http (LISTEN) nginx   6325 nobody    6u  IPv4  26324      0t0  TCP *:http (LISTEN)

4、升級到新版本

版本升級其實就是針對二進制文件的升級,過程如下:

[root@nginx ~]# /usr/local/nginx-1.12.2/sbin/nginx -v nginx version: nginx/1.12.2 [root@nginx ~]# cd /usr/local/nginx-1.12.2/sbin/ [root@nginx sbin]# mv nginx nginx-1.12.2 #首先備份原來的舊版本nginx二進制文件 [root@nginx sbin]# cp /usr/local/nginx-1.14.2/sbin/nginx ./ #拷貝新版本的二進制文件到當前目錄

接下來進行平滑升級操作

[root@nginx ~]# ps -ef|grep nginx root       6324      1  0 09:06 ?        00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx nobody     6325   6324  0 09:06 ?        00:00:00 nginx: worker process root       6338   1244  0 09:11 pts/0    00:00:00 grep --color=auto nginx [root@nginx ~]# kill -USR2 6324 [root@nginx ~]# ps -ef|grep nginx root       6324      1  0 09:06 ?        00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx nobody     6325   6324  0 09:06 ?        00:00:00 nginx: worker process root       6340   6324  0 09:12 ?        00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx nobody     6341   6340  0 09:12 ?        00:00:00 nginx: worker process root       6343   1244  0 09:12 pts/0    00:00:00 grep --color=auto nginx

這時新的master進程已經(jīng)正常開啟,但老的work進程也存在,所以我們使用下面的命令,將老的work進程發(fā)出平滑停止的信號,如下:

[root@nginx ~]# kill -WINCH 6324 [root@nginx ~]# ps -ef|grep nginx root       6324      1  0 09:06 ?        00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx root       6340   6324  0 09:12 ?        00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx nobody     6341   6340  0 09:12 ?        00:00:00 nginx: worker process root       6346   1244  0 09:14 pts/0    00:00:00 grep --color=auto nginx

此時,老的work進程已經(jīng)停止,接下來我們測試是否能正常訪問:

Nginx版本的平滑升級與回滾怎么實現(xiàn)

可以正常訪問,其實這一平滑升級的動作,對訪問用戶來說是完全感知不到,所以nginx熱部署就已經(jīng)完成了。

[root@nginx ~]# /usr/local/nginx-1.12.2/sbin/nginx -v nginx version: nginx/1.14.2

查看版本也是***的版本,升級完成。

注:如果在版本升級完成后,沒有任何問題,需要關(guān)閉老的master進程的話,可以使用下面的命令:

kill -QUIT old_master_PID

5、版本回滾

對于升級來說,最難的不是升級,而是回滾,因為在實際生產(chǎn)環(huán)境回滾的機率是存在,比如:新版本由于某些未知bug導(dǎo)致與現(xiàn)有應(yīng)用不兼容、或出現(xiàn)運行不穩(wěn)定的情況等等。

所以,對運維工程師來說,故障回滾是重點。

在上面的結(jié)果中,我們也能看到老的master進程是一直存在,在沒有手工關(guān)閉前,它是不會自已關(guān)閉的,這種設(shè)計是有好處的,好處就是為了升級新版本后,如果出現(xiàn)問題能及時快速的回滾到上一個穩(wěn)定版本。

[root@nginx ~]# ps -ef|grep nginx root       6324      1  0 09:06 ?        00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx root       6340   6324  0 09:12 ?        00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx nobody     6341   6340  0 09:12 ?        00:00:00 nginx: worker process root       6350   1244  0 09:23 pts/0    00:00:00 grep --color=auto nginx [root@nginx ~]# cd /usr/local/nginx-1.12.2/sbin/ [root@nginx sbin]# mv nginx nginx-1.14.2 [root@nginx sbin]# mv nginx-1.12.2 nginx [root@nginx sbin]# kill -USR1 6324 [root@nginx sbin]# ps -ef|grep nginx root       6324      1  0 09:06 ?        00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx root       6340   6324  0 09:12 ?        00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx nobody     6341   6340  0 09:12 ?        00:00:00 nginx: worker process root       6355   1244  0 09:24 pts/0    00:00:00 grep --color=auto nginx [root@nginx sbin]# ./nginx -v nginx version: nginx/1.12.2

從上面的結(jié)果發(fā)現(xiàn),已經(jīng)平滑的回滾的上一個版本,接下來測試是否能正常訪問:

Nginx版本的平滑升級與回滾怎么實現(xiàn)

一樣可以正常訪問,所以,這個回滾的操作對用戶來說也是不可感知的。

“Nginx版本的平滑升級與回滾怎么實現(xiàn)”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

本文標題:Nginx版本的平滑升級與回滾怎么實現(xiàn)
標題路徑:http://jinyejixie.com/article4/iichie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序微信公眾號、云服務(wù)器做網(wǎng)站、App開發(fā)網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司
凉山| 巴林右旗| 乐亭县| 上杭县| 东源县| 通州区| 淄博市| 桂林市| 桂林市| 泰兴市| 盘山县| 固原市| 东方市| 资兴市| 凌源市| 吉木乃县| 海林市| 教育| 镇平县| 沛县| 阳新县| 渝北区| 鹤岗市| 凤山市| 信宜市| 太白县| 陆川县| 堆龙德庆县| 桂东县| 黄石市| 察哈| 原平市| 凤凰县| 从化市| 尉氏县| 泰和县| 彰武县| 峨山| 昌黎县| 南木林县| 贵德县|