Nginx平滑升级的详细操作方法

2019-10-17 20:55:18王冬梅

nobody    6248  6241  0 10:51 ?        00:00:00 nginx: worker process       
nobody    6249  6241  0 10:51 ?        00:00:00 nginx: worker process       
nobody    6250  6241  0 10:51 ?        00:00:00 nginx: worker process       
nobody    6251  6241  1 10:51 ?        00:00:00 nginx: worker process       
nobody    6252  6241  0 10:51 ?        00:00:00 nginx: cache manager process 
nobody    6253  6241  0 10:51 ?        00:00:00 nginx: cache loader process 
luming    6310 25051  0 10:51 pts/1    00:00:00 grep --color=auto nginx 
nobody    7995 10419  0 Jan12 ?        00:20:37 nginx: worker process is shutting down 
nobody    7996 10419  0 Jan12 ?        00:20:11 nginx: worker process is shutting down 
nobody    7998 10419  0 Jan12 ?        00:20:04 nginx: worker process is shutting down 
nobody    8003 10419  0 Jan12 ?        00:20:12 nginx: worker process is shutting down 
root     10419     1  0 Jan08 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx 

可见新的进程有1个master和10个worker,另外还有1个老的master(可以从时间上看出)和4个worker(其他6个老的worker已经处理完所有连接而shutdown了)。还有一个loader进程。过几秒种可以看到worker只有两个了:
root      6241 10419  0 10:51 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx 
nobody    6242  6241  1 10:51 ?        00:00:00 nginx: worker process       
nobody    6243  6241  0 10:51 ?        00:00:00 nginx: worker process       
nobody    6244  6241  0 10:51 ?        00:00:00 nginx: worker process       
nobody    6245  6241  0 10:51 ?        00:00:00 nginx: worker process