nginx平滑升级

1. 开始之前先查看一下当前使用的版本。

# /usr/local/nginx/sbin/nginx -V
nginx: nginx version: nginx/1.0.5
nginx: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)
nginx: TLS SNI support disabled
nginx: configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-cc-opt=-O3 --with-cpu-opt=opteron --with-http_gzip_static_module

2.下载新版本:http://nginx.org/en/download.html
然后:解压 > 便以前的准备 > 编译

# tar zxvf nginx-1.9.12.tar.gz
# cd nginx-1.9.12
# ./configure 
--user=www 
--group=www 
--prefix=/usr/local/nginx 
--with-http_stub_status_module 
--with-http_ssl_module 
--with-http_flv_module 
--with-cc-opt='-O3' 
--with-cpu-opt=opteron 
--with-http_gzip_static_module
# make

3. 执行完后,这里不用在 make install 了,接下来重名/sbin/nginx为nginx.old

# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old

4. 复制编译后objs目录下的nginx文件到nginx的安装目录sbin/下

# cp objs/nginx /usr/local/nginx/sbin/

5. 测试一下新复制过来文件生效情况:

# /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

6. 让nginx把nginx.pid文件修改成nginx.pid.oldbin,随即启动nginx,实现不间断服务运行

# kill -USR2 `cat /usr/local/nginx/nginx.pid`(发送平滑升级信号将旧的nginx.pid文件添加后缀nginx.pid.oldbin)
#kill  -WINCH(平缓停止worker process) `cat /usr/local/nginx/nginx.pid.oldbin
# kill -QUIT `cat /usr/local/nginx/nginx.pid.oldbin`

7. 升级完成了,最后在看一下升级后的版本

此条目发表在日记分类目录,贴了标签。将固定链接加入收藏夹。

发表评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.