Nginx平滑升级
1、源码包下载:http://nginx.org/en/download.html (nginx-1.20.2.tar.gz)
2、查看旧版本安装模块:
nginx -V nginx version: nginx/1.18.0 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 --with-http_ssl_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-pcre
3、编译不安装
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-pcre
make
注:make后会生成一个objs文件夹
[root@k8s-master nginx-1.23.1]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@k8s-master nginx-1.23.1]#
4、替换二进制文件
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old cp /root/nginx-1.23.1/objs/nginx /usr/local/sbin/
5、平滑升级
cd /usr/local/nginx/sbin/ ./nginx -V #检查当前版本 nginx version: nginx/1.23.1 ./nginx -t #检查nginx配置文件 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
#查看nginx进程信息
ps -ef|grep nginx
#删除旧版本的nginx进程信息
kill -USR2 PID【旧版本Nginx主进程号】
#发送WINCH信号给旧的主进程。然后,他的工作进程将从容关闭
kill -WINCH PID【旧版本的Nginx主进程号】
#删除nginx旧主进程
kill -QUIT PID【旧主进程号】
6、如果多台相同环境的nginx需要升级,只需要将nginx二进制文件传到对应的/usr/local/nginx/sbin/下,执行平滑升级过程就可以了。

浙公网安备 33010602011771号