nginx热升级流程

1. 替换二进制文件(编译安装时路径要保持一直,否则新老版本nginx 无法共享同一个配置文件)

2. 向原nginx master 进程发送 USR2 信号。

master 进程pid 会进行mv 操作 重命名为 pid.old.bin

master 进程用新的二进制文件启动新的 nginx master 进程

[root@node3 ~]# ps -ef |grep nginx
root      1334     1  0 6月13 ?       00:00:00 nginx: master process /usr/sbin/nginx
nginx     1978  1334  0 10:25 ?        00:00:00 nginx: worker process
nginx     1979  1334  0 10:25 ?        00:00:00 nginx: worker process
nginx     1980  1334  0 10:25 ?        00:00:00 nginx: cache manager process
root      2013  1334  0 10:31 ?        00:00:00 nginx: master process /usr/sbin/nginx
nginx     2014  2013  0 10:31 ?        00:00:00 nginx: worker process
nginx     2015  2013  0 10:31 ?        00:00:00 nginx: worker process
nginx     2016  2013  0 10:31 ?        00:00:00 nginx: cache manager process
nginx     2017  2013  0 10:31 ?        00:00:00 nginx: cache loader process
root      2055  1833  0 10:31 pts/0    00:00:00 grep --color=auto nginx


[root@node3 ~]# ls -l /var/run/nginx.pid* | cat
-rw-r--r--. 1 root root 5 6月 14 10:31 /var/run/nginx.pid
-rw-r--r--. 1 root root 5 6月 13 23:31 /var/run/nginx.pid.oldbin

3. 向 老nginx master 进程 发送 WINCH  信号原woker 进程停止

[root@node3 ~]# ps -ef |grep nginx
root      1334     1  0 6月13 ?       00:00:00 nginx: master process /usr/sbin/nginx
root      2013  1334  0 10:31 ?        00:00:00 nginx: master process /usr/sbin/nginx
nginx     2014  2013  0 10:31 ?        00:00:00 nginx: worker process
nginx     2015  2013  0 10:31 ?        00:00:00 nginx: worker process
nginx     2016  2013  0 10:31 ?        00:00:00 nginx: cache manager process
nginx     2017  2013  0 10:31 ?        00:00:00 nginx: cache loader process
root      2057  1833  0 10:32 pts/0    00:00:00 grep --color=auto nginx

4. 回滚旧版本 

kill -HUP  1334  reload 老进程

kill -QUIT  2013  停止新的 master

5. 继续使用 新版本

kill -QUIT  2013

原文地址:https://www.cnblogs.com/leleyao/p/13124062.html