nginx学习(三):nginx的进程模型
概述
nginx 进程分为 master进程和work进程
1.打开配置文件查看,这里我修改为2
[ conf]# vim nginx.conf #user nobody; worker_processes 2;
2.重启,进入sbin 目录
./nginx -s reload
3.nginx 常用命令
./nginx -s stop # 停止 ./nginx -s quit # 退出 ./nginx -s reload #重启 ./nginx -t #测试配置文件是否正确
4.查看
[]# ps -ef|grep nginx root 18496 1 0 Dec14 ? 00:00:00 nginx: master process ./nginx nobody 28522 18496 0 09:49 ? 00:00:00 nginx: worker process nobody 28523 18496 0 09:49 ? 00:00:00 nginx: worker process root 28530 28497 0 09:50 pts/0 00:00:00 grep --color=auto nginx
进程模型图
这里是官网对于nginx reload的介绍
nginx -s reload Once the master process receives the signal to reload configuration, it checks the syntax validity of the new configuration file and tries to apply the configuration provided in it. If this is a success, the master process starts new worker processes and sends messages to old worker processes, requesting them to shut down. Otherwise, the master process rolls back the changes and continues to work with the old configuration. Old worker processes, receiving a command to shut down, stop accepting new connections and continue to service current requests until all such requests are serviced. After that, the old worker processes exit.
Nginx服务不会终止,主进程检查配置,应用配置的过程。主进程会启动一个新的工作进程处理新来的请求。主进程发送消息给老的工作进程,通知老的进程不在接受请求,处理完现有的请求后退出(优雅退出)
总结
nginx的每个进程都是独立的,相互之间是安全的。一个worker 宕机了,其它work还是继续工作,相互没有影响。这里我只是入门,更多关于这方面的知识还需要学习
相关推荐
nginxs 2020-11-14
Guanjs0 2020-11-13
小木兮子 2020-11-11
yserver 2020-11-11
ssihc0 2020-11-11
windle 2020-11-10
HanksWang 2020-11-10
liuchen0 2020-11-10
Freshairx 2020-11-10
ccschan 2020-11-10
liwf 2020-11-10
Guanjs0 2020-11-09
AderStep 2020-11-09
zrtlin 2020-11-09
mqfcu 2020-11-10
windle 2020-10-29