In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Nginx is a super stable server, which usually does not need to be restarted because of overload. The purpose of restarting is to modify the configuration file and load it.
In the beginning, I used the most direct way to restart
[@ more@] killall-9 nginx;/data/nginx/sbin/nginx
If the machine is slow and the kill process cannot be killed in an instant, you can execute it again. This restart method is not particularly safe. If the configuration is incorrect, the restart will fail. You need to modify the configuration file and then start it again, which will take some time. However, for the http world, which is generally not strict at present, this time will not cause much loss, as long as it is not done at a critical moment. If you want to follow this restart method, I suggest you test it first.
And then I saw an even more wonderful restart on nginx.net.
Kill-HUP $pid ($pid is the process number of the nginx master process)
I usually use it like this.
Kill-HUP `cat / data/nginx/logs/ nginx.pid`
The advantage of this approach is to achieve a "smooth restart". As can be seen in ps-aux, the nginx starts the new process first, and the old process still provides services. After a period of time, the old process service is automatically shut down, and the new process continues to serve. But this approach also has drawbacks, if the configuration file is wrong, or resources conflict, then the restart fails, but nginx does not have any hints! This will often find that the changed configuration file does not take effect, and it is more difficult to find the problem.
So, finally mixed up the problem, got a nginx.sh, this version of nginx.sh still did not solve the kill-HUP resource conflict problem, but solved the configuration file problem. Resource conflicts, such as port 80 is occupied, the log file directory has not been created, I will think of a way.
#! / bin/sh
BASE_DIR='/data/'
${BASE_DIR} nginx/sbin/nginx-t-c ${BASE_DIR} nginx/conf/nginx.conf > & ${BASE_DIR} nginx/logs/nginx.start
Info= `cat ${BASE_DIR} nginx/logs/ nginx.start`
If [`echo $info | grep-c "syntax is ok" `- eq 1]; then
If [`ps aux | grep "nginx" | grep-c "master" `= = 1]; then
Kill-HUP `cat ${BASE_DIR} nginx/logs/ nginx.pid`
Echo "ok"
Else
Killall-9 nginx
Sleep 1
${BASE_DIR} nginx/sbin/nginx
Fi
Else
Echo "# error: #"
Cat ${BASE_DIR} nginx/logs/nginx.start
Fi
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.