您的位置:首页 > 运维架构 > Nginx

Nginx的平滑升级

2016-02-01 23:24 155 查看
有时,我们需要对我们的服务器进行升级更高版本。此时,如果我们强行将服务器停止然后直接升级,这样原来在服务器上运行着的进程就会被影响。如何解决这个问题呢?可以通过平滑升级的方式来解决。平滑升级时,不会停掉在运行着的进程,这些进程会继续处理请求,但不会再接受新请求,在这些老进程在处理完还在处理的请求后,停止。此平滑升级的过程中,新开的进程会处理新请求。

1、查看当前版本

[root@Admin /]# cd /opt/nginx/sbin/
[root@Admin sbin]# ./nginx -V
nginx version: nginx/1.8.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
configure arguments: --prefix=/opt/nginx/


2、升级到新的版本

下载新版安装包到/tmp目录下
[root@Admin tmp]# ls
nginx-1.8.0.tar.gz   nginx-1.9.10.tar.gz

解压到当前目录
[root@Admin tmp]# tar -zxvf nginx-1.9.10.tar.gz

进入解压目录进行以下操作
[root@Admin tmp]# cd nginx-1.9.10
[root@Admin nginx-1.9.10]# ./configure
[root@Admin nginx-1.9.10]# make

进入已安装的nginx目录下,备份当前使用的nginx
[root@Admin nginx-1.9.10]# cd /opt/nginx/sbin/
[root@Admin sbin]# cp nginx nginx.old
[root@Admin sbin]# ls
nginx  nginx.old

将新版本的编译文件复制到安装目录
[root@Admin sbin]# cd /tmp/nginx-1.9.10
[root@Admin nginx-1.9.10]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src
[root@Admin nginx-1.9.10]# cp -rfp objs/nginx /opt/nginx/sbin/
cp:是否覆盖"/opt/nginx/sbin/nginx"? y

查看是否升级成功
[root@Admin nginx-1.9.10]# cd /opt/nginx/sbin/
[root@Admin sbin]# ./nginx -V
nginx version: nginx/1.9.10
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
configure arguments:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: