Restart Mysql automatically when ubuntu on an EC2 micro instance kills it when memory runs out

When the system runs out of memory, ubuntu 12.04 kills the mysql process:

Out of memory: Kill process 17074 (mysqld) score 146 or sacrifice child

Thus, the process ends with the murdered. This occurs during server load peaks and mainly because apache becomes wild and there is remaining available memory. Possible approaches could be:

  • Change mysql priority somewhere so that it doesn't get killed (maybe a bad fix, as something else will be killed)
  • Monitor the state of mysql and automatically restart whenever it is killed (the one I think of, but don't know how to do this).

How do you see him?

+5
source share
2 answers

mysql ( cron) , :

* * * * * service mysql status | grep running || service mysql restart
+3

All Articles