nginx平滑升级(2022.12.13)

相关视频教程:
https://www.bilibili.com/video/BV1BK411W7hn
相关文章:
https://blog.csdn.net/u012885136/article/details/122054931

nginx平滑升级

1、旧版本的nginx

ps -ef | grep nginx

[root@iZwz92fv0joers3oc6eg6dZ /]# ps -ef | grep nginx
root     23932 10585  0 16:53 pts/5    00:00:00 grep --color=auto nginx
root     27493     1  0 Feb25 ?        00:00:00 nginx: master process nginx
nginx    31021 27493  0 15:53 ?        00:00:00 nginx: worker process
nginx    31022 27493  0 15:53 ?        00:00:00 nginx: worker process

2、解压新版本nginx ,进行编译安装

tar -xvf nginx-1.20.2.tar.gz -C /usr/local/src/
sudo ./configure --prefix=/usr/local/nginx2 --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module

3、make、make install

make
make install

4、用新版本的启动程序去 替换 旧的启动程序

在这里插入图片描述

① 直接覆盖 ->新版本出现问题,就不能回退了
② 先备份旧版本启动程序,在拷贝新的

在旧版本 mv nginx nginx.bak
拷贝新的 cp/usr/local/nginx2/sbin/nginx

5、给旧版本进程发一个信号,平滑升级,会出现新的进程

kill -USR2 121823

在这里插入图片描述

6、从容的关掉旧的工作进程

kill -WINCH 121823

在这里插入图片描述

7.最后将旧的主进程干掉(旧的主进程没有关掉,可以进行回退kill -HUB 121823)

8.从容关闭旧进程:kill -QUIT 121823

重新加载配置文件:./nginx -s reload
可以查看端口:cat /var/run/nginx.pid

猜你喜欢

转载自blog.csdn.net/weixin_44531966/article/details/128302155