-2

My system is configured as follows:

  • database server on a linux server
  • web application on another linux server

For sanitation purposes I would like to restart these servers during night at least once a week.

The constraints are :

  • when the web application is loaded the database must be already online
  • the downtime should be as small as possible
  • don't want to rely on time synchronization between the servers

Can you suggest a simple and clean way to achieve this ?

I suppose I have to create a cron job but besides issuing a server shutdown I don't know how to wait the launch of the web application till the database is online again.

Sven
  • 98,649
  • 14
  • 180
  • 226
Filippo
  • 377
  • 5
  • 18
  • Can you please clarify what "sanitation purposes" means? – AD7six Dec 03 '14 at 10:49
  • I agree with your comment below "it would be much more beneficial to fix the root-cause" but sometimes those servers stop functioning without any apparent reason. Last time the database was offline, I tried to check was what happening but the server didn't accept ssh connection so I was cut out. After restarting it I found nothing useful in the logs. Don't know if a scheduled restart can make the system more robust and reliable, I don't like it but I'm almost convinced it is worth to try. – Filippo Dec 03 '14 at 12:18

1 Answers1

1

Restarting your servers for "sanitation purposes" is a poor approach to administration. Do not do this unless you are installing updates or have legitimate reasoning to.

If you actually want to proceed and you assume your database server is going to take a while to reboot (and your web server isn't), you could just schedule the reboot on the web server to occur a few minutes after the web node (so as to render a nice error page in the duration). Alternatively, you could write a script that cleanly shuts down your database server and makes sure it comes back online before restarting the web server.

edit: I also notice you mentioned master/slave in your title. The topology you described does not include any master/slave.

Peter
  • 1,450
  • 2
  • 17
  • 27
  • I suppose the web app is being erroneously considered the master, and the db the slave. I don't think any suggestion ala "you shouldn't do that, but if you want to here's how" is a good one (at least, not without a lot more emphasis/space dedicated to "you're doing it wrong, don't do that, why are you thinking to do that anyway?"). – AD7six Dec 03 '14 at 10:34
  • web and a db node does not constitute a master/slave arrangement. If you don't appreciate my answer, that's your call. – Peter Dec 03 '14 at 10:38
  • Indeed it's not; I don't and it is =). I appreciate the time you took to write an answer though. If "sanitation purposes" is anything along the lines of emptying the tmp folder, some process has a memory leak and dies after 8 days running, I don't like my uptime counter being so high etc. (I/we don't know what that means, but it's highly unlikely IMO to actually require a reboot) it would be much more beneficial to fix the root-cause/misconception rather than aide the user to do what they ask. Helping people to hurt themselves isn't really helping. – AD7six Dec 03 '14 at 10:45
  • Sorry, I thought you were OP in my previous comment. :) I agree with you. – Peter Dec 03 '14 at 10:51