MariaDB stopped working

I followed the documentation and went on with a smooth provision and deploy, thanks for all your great work, I love it and it’s absolutely amazing!

However today, all the sudden I’m getting a error establishing a database error (not being able to establish a connection) in my production environment. I’m using Digital Ocean with Ubuntu 16.04.

As I was about to troubleshoot, I ssh’d into the server as admin, ran mysql -u root -p and the password I have provided in group_vars/production/vault.yml but I get the following error:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (111 “Connection refused”)

So I did service mysql restart and all the sudden everything works great again. Has anyone experienced this and can recommend some troubleshooting to prevent it from happening again?

1 Like

I’ve seen that happen when the OOM Killer killed the MySQL server (example discussion). You could check whether that may have happened to you by checking for an oom-killer log entry related to mysql in your server’s kernal log.

# this might work
grep 'oom-killer' /var/log/kern.log

If it was out-of-memory, you could scale the server’s resources and/or increase swapfile_size.

2 Likes

Thanks for your reply! That seems to be the reason. Right now, I have the cheapest Digital Ocean alternative with 512 mb ram, naively I thought it would do it since I have no traffic right now.