apache2 reload、restart、graceful有什么区别? [英] What is the difference between apache2 reload, restart, graceful?
问题描述
我在一个项目中使用 apache2,我想知道这些命令之间到底有什么区别:
I am using apache2 for a project and I am wondering what is exactly the difference between these commands:
service apache2 restart
service apache2 reload
service apache2 graceful
推荐答案
四种不同的停止/重启方式之间的主要区别在于主进程对其线程和自身做了什么.
There main difference between the four different ways of stopping/restarting are what does the main process do about its threads, and about itself.
注意Apache推荐使用apachectl -k
作为命令,对于systemd,命令替换为httpd -k
Note that Apache recommends using apachectl -k
as the command, and for systemd, the command is replaced by httpd -k
apachectl -k stop
或 httpd -k stop
这告诉进程杀死它的所有线程然后退出
This tells the process to kill all of its threads and then exit
apachectl -k graceful
或 httpd -k graceful
Apache 会在空闲时通知它的线程退出,然后 apache 重新加载配置(它不会自己退出),这意味着统计信息不会重置.
Apache will advise its threads to exit when idle, and then apache reloads the configuration (it doesn't exit itself), this means statistics are not reset.
apachectl -k restart
或 httpd -k restart
这类似于停止,因为进程会终止其线程,但随后进程会重新加载配置文件,而不是自行终止.
This is similar to stop, in that the process kills off its threads, but then the process reloads the configuration file, rather than killing itself.
apachectl -k graceful-stop
或 httpd -k graceful-stop
这就像 -k graceful
一样,但它不会重新加载配置,而是停止响应新请求,并且只在旧线程存在时才有效.将其与 httpd
的新实例相结合,可以在更新配置文件的同时运行并发 apache 非常强大.
This acts like -k graceful
but instead of reloading the configuration, it will stop responding to new requests and only live as long as old threads are around. Combining this with a new instance of httpd
can be very powerful in having concurrent apaches running while updating configuration files.
来源:https://httpd.apache.org/docs/2.4/stopping.html
建议:使用 -k graceful
除非主进程本身有问题,在这种情况下使用 -k stop
和 -k start 的组合
或 -k graceful-stop
和 -k start
是选择的选项.
Recommendation: Use -k graceful
unless there is something wrong with the main process itself, in which case a combination of -k stop
and -k start
or -k graceful-stop
and -k start
are the options of choice.
这篇关于apache2 reload、restart、graceful有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!