nginx的平滑升级
方案(一)
1. 查看原编译参数
[root@anonymous ~]# nginx -V
[root@anonymous ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
2. 解压缩,进入软件安装目录,添加echo-nginx-module模块
预编译/编译/安装:
[root@anonymous ~]# tar xf nginx-1.20.1.tar.gz
[root@anonymous ~]# cd nginx-1.20.1
[root@anonymous nginx-1.20.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --add-module=/usr/src/echo-nginx-module
root@anonymous nginx-1.20.1]# make && make install
3. 直接升级:make upgrade
方案(二)
1. 查看原编译参数
[root@anonymous ~]# nginx -V
[root@anonymous ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
2. 解压缩,进入软件安装目录,添加echo-nginx-module模块
预编译/编译/安装:
[root@anonymous ~]# tar xf nginx-1.20.1.tar.gz
[root@anonymous ~]# cd nginx-1.20.1
[root@anonymous nginx-1.20.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --add-module=/usr/src/echo-nginx-module
root@anonymous nginx-1.20.1]# make && make install
3. 生成新的master进程:
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
[root@node3 nginx-1.16.0]# ps -ef |grep "[n]ginx"
root 8054 1 0 21:07 ? 00:00:00 nginx: master process
/usr/local/nginx/sbin/nginx
nginx 8097 8054 0 21:09 ? 00:00:00 nginx: worker process
nginx 8098 8054 0 21:09 ? 00:00:00 nginx: worker process
root 8134 8054 0 21:13 ? 00:00:00 nginx: master process
/usr/local/nginx/sbin/nginx
nginx 8135 8134 0 21:13 ? 00:00:00 nginx: worker process
nginx 8136 8134 0 21:13 ? 00:00:00 nginx: worker process
4. 优雅退出老worker进程:
# 向老的master进程发信号:
[root@anonymous nginx-1.20.1]# kill -WINCH 8054
[root@anonymous nginx-1.20.1]# ps -ef |grep "[n]ginx"
root 8054 1 0 21:07 ? 00:00:00 nginx: master process
/usr/local/nginx/sbin/nginx
root 8134 8054 0 21:13 ? 00:00:00 nginx: master process
/usr/local/nginx/sbin/nginx
nginx 8135 8134 0 21:16 ? 00:00:00 nginx: worker process
nginx 8136 8134 0 21:16 ? 00:00:00 nginx: worker process
5. 抉择:
5.1 回滚:
5.1.1 重新拉起老的worker进程:
[root@anonymous nginx-1.20.1]# kill -HUP 8054
[root@anonymous nginx-1.20.1]# ps -ef |grep "[n]ginx"
root 8054 1 0 21:07 ? 00:00:00 nginx: master process
/usr/local/nginx/sbin/nginx
root 8134 8054 0 21:13 ? 00:00:00 nginx: master process
/usr/local/nginx/sbin/nginx
nginx 8135 8134 0 21:16 ? 00:00:00 nginx: worker process
nginx 8136 8134 0 21:16 ? 00:00:00 nginx: worker process
nginx 8154 8054 1 21:19 ? 00:00:00 nginx: worker process
nginx 8155 8054 1 21:19 ? 00:00:00 nginx: worker process
5.1.2 退出新的master进程:
[root@anonymous nginx-1.20.1]# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid`
[root@anonymous nginx-1.20.1]# ps -ef |grep "[n]ginx"
root 8054 1 0 21:07 ? 00:00:00 nginx: master process
/usr/local/nginx/sbin/nginx
nginx 8154 8054 0 21:19 ? 00:00:00 nginx: worker process
nginx 8155 8054 0 21:19 ? 00:00:00 nginx: worker process
5.2 新生:
# 经过一段时间测试,服务器没问题,退出老的master:
root@anonymous nginx-1.20.1]# kill -QUIT 8054
root@anonymous nginx-1.20.1]# ps -ef |grep "[n]ginx"
root 8134 1 0 21:24 ? 00:00:00 nginx: master process
/usr/local/nginx/sbin/nginx
nginx 8135 8134 0 21:24 ? 00:00:00 nginx: worker process
nginx 8136 8134 0 21:24 ? 00:00:00 nginx: worker process
相关文章
- 12-14让 Mongoose 不再重复链接数据库(如何正确连接以解决升级后的报错)
- 12-14理解 nginx 的location 块匹配规则。
- 12-14python2升级到python3时遇到的编码问题汇总
- 12-14不识庐山真面目——我在虚拟网的打怪升级之路
- 12-14nginx反向代理proxy_pass url后加"/"与不加"/"的区别
- 12-14SpringCloud服务的平滑上下线
- 12-14clojure – 为从nginx反向代理转发的请求添加唯一ID
- 12-14Tornado websocket演示的Nginx配置?
- 12-14php – Nginx上的Magento – 配置
- 12-14关于 锁的四种状态与锁升级过程 图文详解