Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've searched, and all resources are about how to perform the restart.

I know how to reload, restart, stop; Apache, MySQL, etc and how to restart the OS.

My question is how to perform a server restart safely. I've just installed some updates which require a server restart, as there were some kernel updates.

It's Ubuntu Server 13.10, on a dedicated server. I connect via SSH.

The server is running perfectly, and it's a production server, so I'm wanting to know if there's a proper/correct procedure to follow, or if sudo shutdown -r now or sudo restart really is all that's needed, or should I shut down the major processes like the database down manually first, so I know they're safely closed, before I restart the host OS?

Will my Percona DB server which is mostly InnoDB be shutdown correctly, or just ditched? How careful will Ubuntu server be about making sure all processes have flushed to disk, and given the "I'm ok to be halted" signal before it ditches them and reboots?

Thanks.

share|improve this question
    
Stop the database just in case and then restart as you said with shutdown -r now . Do you have a plan if the server doesn't restart (attach a console etc)? –  LinuxDevOps Apr 1 at 18:22
    
Hi, thanks. "just in case" What are the potential risks? The DB is a binlog master if that changes anything. Also, no I've no plan if it doesn't restart. Frantically call the datacentre to run over and press the button I guess (sorry for the flippancy, you just blew a hole in my confidence!) :) –  i-CONICA Apr 1 at 18:25
    
It's rare but it happens sometimes that when you shut down the server if mysql is not killed gracefully it may leave corrupted tables so it's a good idea to stop it first. I'd check with the data centre what options you have in case the server doesn't boot up. –  LinuxDevOps Apr 1 at 18:29

3 Answers 3

up vote 2 down vote accepted
  1. Have a plan regarding how to proceed if the server doesn't come up after the kernel upgrade
  2. Turn off the client-facing network connections (web server) so there are no more writes to the database
  3. Stop the database (shutting down services can be done in order by using the init scripts as suggested)
  4. Issue the reboot command
share|improve this answer

You should configure your systems init scripts so that these steps occur in proper sequence automatically when your switch runlevels and that dependencies are satisfied (first shut down apache; then shut MySQL, etc). Really this is the purpose of the init script hierarchy that exists on Linux systems. This hierarchy is designed so that you may perform graceful shutdowns satisfying the conditions you require.

The kernel definitely flushes everything to disk, and generally a shutdown will send kill "TERM" signals to each process to try to get each process to exit gracefully. So really the only thing you need to do is make sure each application is shutdown in proper sequence by giving it proper place in the init scripts.

init scripts and associated control files are located in /etc/init.d and /etc/default

share|improve this answer

In my experience a maintenance reboot should start with the outer layer. So firstly the app server (apache then php-fpm or uwsgi etc.) followed by the database(s). If you are as paranoid as I am, run htop and netstat to ensure everything is closed. Then if you want to ensure that the hdd cache is flushed you may call sync.

All that is left is a reboot.

In most cases it should be safe to just call the reboot, but safety is the best policy.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.