MySQL stops working occassionally

March 6, 2014 2.8k views
I am running a 1GB ram 12.04 Ubuntu droplet and using it as a web server. Occasionally, MySQL will just stop working. I have maybe 4 small sites that don't receive very much traffic at all. I originally started out with 512mb ram and was having the same kind of issues, but then I enabled swap space and that seemed to help a little, but I was still having issues. Then I upgraded to 1GB and I was great for a few days. But then this morning, boom. I had to SSH into my droplet and "service mysql restart" to get it up again. I've installed some monitoring software to help diagnose my problems. Timeline: 8:10 Free Memory - 444mb Free Swap - 502mb Buffers - 69mb MySQL - UP HTTP - 17ms CPU - 0.3% 8:15 Free Memory - 75mb Free Swap - 502mb Buffers - 69mb MySQL - UP HTTP - 16ms CPU - 8.3% 8:20 Free Memory - 484mb Free Swap - 502mb Buffers - 65mb MySQL - UP HTTP - 16ms CPU - 20.1% 8:25 Free Memory - 465mb Free Swap - 502mb Buffers - 65mb MySQL - UP HTTP - 15ms CPU - 5.7% 8:30 Free Memory - 52mb Free Swap - 0mb Buffers - 0mb MySQL - DOWN HTTP - 565ms CPU - 22% 8:35 Free Memory - 679mb Free Swap - 454mb Buffers - 1mb MySQL - DOWN HTTP - 15ms CPU - 16% 8:40 Free Memory - 662mb Free Swap - 456mb Buffers - 4mb MySQL - DOWN HTTP - 16ms CPU - 0.3% What are some steps I can take to figure out what is causing this?
4 Answers
I'm no expert at all, but it seems that your swap space gets cleared and then MySQL fails. I'd poke around there.
I had the same issue on a 512MB droplet running WordPress. The only way i got this working was by swapping out Apache for Nginx. Haven't had any problems since, but i can't get caching to work, so that's another problem.

I wished i had known about these issues before i signed up *sigh*

I would suggest you look at this setup, also look into "easyengine" thats what i am doing.
Check your MySQL logs to see why mysqld is stopping and what error it encounters. Best place to start.

I know that this is an old thread, but I have the same issue on two of my droplets so I'd like to share my progress thus far.

dmesg hints that mysqld went down due to lack of available memory.
The mysql.log and mysql.err has nothing.

Found this thread when searching for people with a similar issue on digitalocean. Apparently, this is a common problem beyond digitalocean.

People have suggested on some blogs to optimize the my.cnf, which for me is in /etc/mysql/my.cnf
I'm at a stage were I'm trying to figure out which variables to alter in the my.cnf in order resolve the case.

I'll update everyone if I come up with a solution.
Thank you.

Have another answer? Share your knowledge.