In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, the editor will share with you the relevant knowledge about what the method of nginx smooth restart and smooth upgrade is. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.
Nginx smooth restart
If you modify the nginx configuration file (nginx.conf) and want to restart nginx, you can send a system signal to Nginx's master process to do so.
Smoothly restart the main process
Send HUB signals to the master process (reload command)
Nginx-s reloadkill-s gighup Nginx main process number
The master process checks whether the configuration syntax is correct
If there is a configuration file or syntax error, the following code appears
Master opens the listening port
The master process starts a new worker child process with the new configuration file
The master process sends quit signals to the old worker child process
The old worker child process turns off listening and shuts down the process after processing the current connection
Graphic illustration
When nginx receives a SIGHUP signal from the system, nginx attempts to parse the configuration file (if a profile is specified, the specified profile is used, otherwise the default is used), and if the profile is successfully parsed (indicating that there is no error in the profile), the new profile is applied. Nginx then starts the new worker child process, then waits for the old worker child process to complete its task, and then closes the old worker child process. If you encounter an old worker child process in progress, the old worker child process continues to serve the currently connected customer, and when all client services are completed, the old worker child process is shut down.
If the application of the new profile fails, nginx will continue to run with the old profile.
Nginx smooth upgrade
When you need to upgrade or add / remove a running nginx server module, you can replace the old version of the executable with a new version of the recompiled nginx executable without interrupting the service.
Smooth upgrade main process
Replace the old nginx profile with the new nginx profile (if the underlying directory structure requires special operations)
Replace the old executable with a new executable, and it's best to back up the old configuration file before replacing it.
Send USER2 signals to the master process
Kill-s SIGUSER2 nginx process number
The master process modifies the pid file and executes the new configuration file with the suffix .oldbin
The master process of the older version of nginx renamed nginx.pid to nginx.oldbin
The master process starts a new master process with the new nginx configuration file
Execute the new configuration file and start the new master process and the corresponding worker child process in turn. At this time, the new nginx process and the old nginx process run at the same time to process the input request together.
Verify that the new function meets the functional expectations. If so, send a WINCH signal to the old master process, and the old worker child process exits.
After running for a period of time, make sure that the new configuration file is in effect, and then use SIGWINCH to signal the old master process to gradually stop the old worker child process
Kill-s SIGWINCH Old nginx process number kill-s SIGQUIT Old nginx process number
This decides whether to use the new version or the old version. If you use the new version, continue to send SIGWINCH signals to the old master. If you need to roll back, send a command.
# nginx will start his worker child process kill-s SIGHUP old master number # nginx close the new configuration file's worker child process kill-s SIGQUIT new master number # nginx force to exit the new master main process kill-s SIGTERM new master number without reloading the configuration file
When the new master exits, the old master conference chu removes the .pid file with the .oldbin suffix, so the rollback is complete. If you try to upgrade successfully and want to keep the new server, you can send a quit signal to the old master to exit and leave the new server to run.
These are all the contents of this article entitled "what is the method of smooth restart and smooth upgrade of nginx?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
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.