nginx 平滑升級tengine

wget   //下載Tengine1.5.1版本

tar zxvf tengine-1.5.1.tar.gz //解壓到當前目錄

cd tengine-1.5.1 //進入到目錄

./configure //執行安裝腳本

make //編譯安裝

mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old //備份nginx的配置文件,路徑參考你本身的

cp -r objs/nginx /usr/local/nginx/sbin/nginx //複製Tengine文件到nginx下

#vi /usr/local/nginx/conf/nginx.conf //編輯nginx.conf,刪除以下代碼
#location /status {
#stub_status on;
#access_log off;
#}

kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
//結束nginx進程

/usr/local/nginx/sbin/nginx -v //查看nginx版本號
返回帶有Tengine版本號等信息則升級成功!

/*
************************************
**卸載Tengine,換回Nginx
************************************
*/
rm -rf /usr/local/nginx/sbin/nginx //刪除Tengine配置文件 

mv /usr/local/nginx/sbin/nginx.lod /usr/local/nginx/sbin/nginx  //恢復備份的nginx配置文件,路徑參考你本身的

/etc/init.d/nginx restart //重啓nginx

/usr/local/nginx/sbin/nginx -v //查看nginx版本號
返回帶有Nginx版本號則卸載成功
nginx

 

 

實驗以下:spa

[root@qike tengine-2.1.0]# kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`  //  平滑升級  會在/usr/local/nginx/logs/ 下生成了nginx.pid.oldbin (之前的nginx進程號)  nginx.pid如今變爲tengine的進程號.
[root@qike tengine-2.1.0]# cd  /usr/local/nginx/logs/
[root@qike logs]# ls -lh
total 48K
-rw-r--r-- 1 root root   46 Jul  4 00:19 aa
-rw-r--r-- 1 root root 5.2K Jun 20 23:29 access.log
-rw-r--r-- 1 root root  17K Aug  2 20:49 error.log
-rw-r--r-- 1 root root    6 Aug  2 20:49 nginx.pid
-rw-r--r-- 1 root root    6 Jul 27 23:36 nginx.pid.oldbin
drwxr-xr-x 2 root root 4.0K Jul  6 14:53 old
-rw-r--r-- 1 root root  209 Jul  4 00:01 test
[root@qike logs]# cat /usr/local/nginx/logs/nginx.pid
31941
[root@qike logs]# cat /usr/local/nginx/logs/nginx.pid.oldbin
24372
[root@qike logs]# ps -ef |grep  nginx    
root     24372     1  0 Jul27 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody   24373 24372  0 Jul27 ?        00:00:14 nginx: worker process                                          
nobody   24374 24372  0 Jul27 ?        00:00:13 nginx: worker process                                          
nobody   24375 24372  0 Jul27 ?        00:00:15 nginx: worker process                                          
nobody   24376 24372  0 Jul27 ?        00:00:12 nginx: worker process                                          
root     31941 24372  0 20:49 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody   31942 31941  0 20:49 ?        00:00:00 nginx: worker process                                          
nobody   31943 31941  0 20:49 ?        00:00:00 nginx: worker process                                          
nobody   31944 31941  0 20:49 ?        00:00:00 nginx: worker process                                          
nobody   31945 31941  0 20:49 ?        00:00:00 nginx: worker process                                          
root     32023 25663  0 20:50 pts/2    00:00:00 grep nginx
[root@qike logs]# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`  //kill -QUIT  舊進程號(老進程)    會把舊的進程和nginx.pid.oldbin 這個文件幹掉rest


[root@qike logs]# ps -ef |grep  nginx
root     31941     1  0 20:49 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody   31942 31941  0 20:49 ?        00:00:00 nginx: worker process                                          
nobody   31943 31941  0 20:49 ?        00:00:00 nginx: worker process                                          
nobody   31944 31941  0 20:49 ?        00:00:00 nginx: worker process                                          
nobody   31945 31941  0 20:49 ?        00:00:00 nginx: worker process                                          
root     32073 25663  0 20:51 pts/2    00:00:00 grep nginx
[root@qike logs]# nginx -v
Tengine version: Tengine/2.1.0 (nginx/1.6.2)

進程

相關文章
相關標籤/搜索