I always used the command:
However, sometimes that causes MySQL issues.
In this article, I am going to show you how to configure dnsmasq DNS server on CentOS 7. Dnsmasq is a very lightweight and simple DNS server. Dnsmasq can be configured to be a DNS server and a DHCP server. 2 If IPTables is running, allow DNS port.DNS uses 53/TCP,UDP. For '-I INPUT 5' section below, Replace it to your own environment.
What's the most graceful way to restart CentOS?
I've seen:
and
How can I gently reboot the machine?
UserUser57722 gold badges77 silver badges1616 bronze badges
5 Answers
There is no better way to restart your server by using anything else than any those commands.
- shutdown is the most common way to stop your system. Adding the argument
-r
and a specific time (or 'now
') will reboot your system instead of halting it after the shutdown sequence. - reboot is a wrapper round shutdown which does some harddisk maintenance (syncing and/or putting in standby mode and not really relevant).
- New versions of
reboot
(>2.74) will initiateshutdown
if not in runlevel 0 or 6. - Most init scripts call halt to make a log in utmp.
Modern distributions will have all tasks covered regardless of the command you are using. Basically they all initiate the shutdown run-time of your SysV (CentOS <7) or systemd (CentOS >=7) scripts (I will call them init scripts for ease of reading).
Shutting down using init scripts step by step stop all your services registered under usually runlevel 'S'. Individual init scripts can have a timeout, like the MySQL init script in CentOS. When the stop argument is given and the daemon will not be shutdown in a fair amount of time, the script will stop and exit giving a failure. The shutdown process will continue as if nothing was wrong, only taking a bit longer and probably print a warning. At the end, when all init scripts are executed, the inevitable will happen: all processes still running will get a
SIGTERM
signal and, after a few seconds (2 or 5), a SIGKILL
. This will clean up the rest before an ACPI call is done to really reboot or shutdown your system.One exception is using the
reboot
command with the -f
option, this will skip executing init scripts and will reboot the system directly.You will be better off fixing the root-cause of your worries: MySQL not shutting down properly.
Often this is due to the massive load of work that needs to be done before the daemon can be exited safely. I once had a MySQL instance with +300.000 tables that took over an hour to exit. Similar issues can be found with systems using huge buffers and sparse I/O availability.
JoffreyJoffrey
A graceful shutdown of Centos 6.x should be done by using the command as root:
This will attempt to stop all running services before shutting down the server gracefully.
Using this command also prevents mySQL socket issues.
Similarly, for a graceful reboot:
You can read a previous answer about a similar question here:
Community♦
GeckoSEOGeckoSEO
When giving remote instructions to end-users and customers, I instruct them to use
poweroff
to shutdown and power the system off. If they want a warm reboot, I suggest that they use the
reboot
command.I suppose one could say that issuing
Ctrl-Alt-Delete
also accomplishes this ;)Community♦
ewwhiteewwhite176k8080 gold badges380380 silver badges734734 bronze badges
I use the command 'init 6' .
init 6 tells the init process to shutdown all of the spawned processes/daemons as written in the init files (in the inverse order they started) and lastly invoke the shutdown -r now command to reboot the machine.
More information can be found on this question.
Community♦
Itai GanotItai Ganot7,0452222 gold badges7171 silver badges124124 bronze badges
I have a feeling you may not like this answer, but THIS answer includes some insight none of the others consider. . . You write:
I always used the command:
shutdown -r now
However, sometimes that causes MySQL issues.
The problem here is NOT your method of shutdown, is the piece of software that can't handle a shutdown properly; MySql.
The ONLY way you can really address this is replace MySql (PostgreSql is a great replacement) OR write your own shutdown script that FIRST coddles MySql like a baby, and when it's happy to be shut down THEN shuts down the system.
... As a person who has specialized in database systems for over 26 years, I can tell you that it's only been in very recent times that MySql has started to get its act together regarding competency at the most important facets of what database systems are for - data security / integrity. Formerly, they have paid less attention to these aspects and more attention to performance. But what good is great performance if you lose data? On SOME applications, like, say, Netflix streaming video recording at what point you're viewing, absolute fidelity may not be particularly important - maybe, even, your customers LIKE the video backing up a bit following a failure. But in a banking system, it's a disaster of epic proportions. Only the data owner can know what's right for them.
Richard TRichard T