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版本号则卸载成功

 

 

实验如下:

[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 这个文件干掉


[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)

posted @ 2015-08-02 21:09  dantes博客  阅读(1471)  评论(0编辑  收藏  举报