Question

Getting regular "Out of memory: Kill process". How to resolve this isse?

Posted July 30, 2013 72.1k views
Regularly I got the following message in syslog file: "Out of memory: Kill process 837 (mysqld) score 59 or sacrifice child". This is really annoying. I already created a swapfile using this tutorial "https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04" but I still get error. Could you please tell me how to fix this issue? My droplet is a $5 one with 512Mb RAM. THe distro is Ubuntu 13.04 x64. (the funny thing is that default mysql configuration worked perfectly on my previous server (VPS Gandi with only 256Mb RAM)
2 comments
  • I’m getting the same thing on $10 plan for apache2 (running wordpress and have basically zero traffic except for myself.

  • Try disabling OOMKiller using this command:

    echo 1 > /proc/sys/vm/overcommit_memory

    You can make it permanent with /etc/sysctl.conf by adding vm.overcommit_memory = 1 and then running sysctl -p

    Just be aware disabling OOMKiller will have negative effects if you actually run out of memory.

    I found even with loosening the ratio to 60% it still killed off my processes with less than 60%.

    Disabling it entirely by setting to 1 fixed my problem I think :)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
35 answers

Try to use a swap file.
Getting this error with a nodejs process et resolved since using a swap

by Justin Ellingwood
Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.

Restarting apache2 and mysql is only a temporary solution, not fixing the root cause.

Follow the swap tutorial. It solved it for me. I have the 5$ droplet and it works fine now :)

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

by Justin Ellingwood
Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.
You can try tweaking /etc/mysql/my.cnf or resizing your droplet to a larger plan.
It might not necessarily be a MySQL problem. Sometimes, other programs hog a server's memory - leaving MySQL too little memory to work with.

Are you running Apache? If so, you should fine-tune Apache2 and MySQL memory usage.

Is it too late for you to copy the config from VPS Gandi, so you can compare it to the config on your droplet?

Guys, I have the same problem.
“You can try tweaking /etc/mysql/my.cnf”
“You should fine-tune Apache2 and MySQL memory usage”

  • is there any step by step explanation of these two?

Thank you!

Same problem here. on $20 per month plan and zero traffic, mysql (on wordpress) keeps stopping (out of memory).

I have the same issue… Really annoying.

I have the same issue… Really annoying. on $10 per month plan

I am facing same issue with $5 plan. My website is not working even. Can anyone from digital ocean helps us here.

I guess this has something to do with DO infra. My Server was running for 2 years with no prob and since last week it is having the same issue. I upgraded to $10 and things are the same

Been fine for the last one year, but got this same issue since last week, plan to upgrade, but it seems will cancel it if has the same issue with @revel .

Any further update?

Thank you.

Same issue…very annoying…can we get something to work [while I migrate everything to AWS]?

Same issue here…

If I use the terminal, I get this error:
“sshexchangeidentification: Connection closed by remote host”

If I try to use the Online Console, every command gets an error like:
“Out of Memory: Kill process … or sacrifice child … ”

What should I do? My server is offline for 3 days and I can’t get it working!
Any help?? Thanks!

Same problem. Have to do “shutdown -r now” several times per day as MySQL seems to get killed often. I considered upgrading to a larger plan but see others are having the same problem with larger plans. I’m surprised there’s no solutions since the months this has been an issue.

Same Issue here!, new website on DO, worked for a month or so then started crashing every day, move it to a new droplets, was fine again for a week now the problem has returned.

Tried to upgrade to a better spec, did not make a difference.

This seem to be a common issue, no response from DO? time to move to another host?

Also getting this, wordpress on 10$,

I am also getting the same thing with the $10 Wordpress plan. Seriously considering moving to a different host.

same here, digging around for answers and I see there has been none given to this question yet…

I too have the same problem, Is there an answer from support team..? It was working fine till last couple of months. What is going on..?

It’s a problem with the servers cgroup configuration.
Disabling cgroups would solve the problem.

Facing the same issue :/

@digitalocean are you going to help your clients or just keep ignoring them ?!

Facing the same issue…

I am facing same issue with $5 plan. My one-click owncloud is not working fine. Very disappointed things.

Same issue here. It’s causing issues with supervisor and database queues, need to be manually restarted daily. I am very surprised DO support has not responded. I may consider migrating to Vultr if I cannot find a solution soon.

Didnt knew about Vultr, I’m opening an account right now there to check it.

The apparent solution is to make a swap file, but the tutorial indicates that a swap file will degrade the SSD drives over time and they dont recommend doing it anywhere and just “upgrade” to fix whatever problem you have.

Looks to me that DO just want people to pay more or cutoff many $5 plans to get bigger customers.

The same problem, just want use wordpress with apache and mysql for my blog. Using droplet for $5
No solutions?

After a bit of digging with information from crash logs and internal mail, I came across this:
http://www.porotal.org/fixing-daily-cron-db-update-failed-database-locked-error-in-ubuntu/

I just solved it by using this two commands line:

sudo service apache2 restart
sudo service mysql restart

Good morning, I have the same problem the mysql stops for no reason I have the most basic plan, how the problem is solved.

Hello,

Just encounter the issue.

I tweaked the default mysql.cnf installed and configured with the Wordpress Droplet config provided by DO.

If the issue disappeared definitively I will update here on the methodology.

I did not go with the swap file path as it was not recommended by DO.

Thanks

The same problem, just want use wordpress with apache and mysql for a site web. Using droplet for $5

This is my Issue too. every time I log into One of my website it keeps happening. Error establishing database connection, and I get out of memory kill process mysqld in ssh console. sometimes it fixes itself in 15-20 seconds. But sometimes I have to turn off and turn on again droplet to solve it. Is that happening cause it needs to increase memory limit? I want to know how to diagnose exactly why this happening and then find the method how to fix it. thanks

Hello, all

You will most definitely need to upgrade your droplet as you’re running out of memory and your application/website needs more resources in order to continue to operate.

What you can also do is to use the MySQLTuner script.

The MySQLTuner is a script written in Perl and allows you to quickly test your MySQL configuration and it gives you suggestions for adjustments to increase performance and stability.

According to the official GitHub page, it supports 300 indicators for MySQL/MariaDB/Percona Server in this last version.

To run the script you could do the following:

  • SSH to your Droplet
  • Download the script:
wget http://mysqltuner.pl/ -O mysqltuner.pl
  • Then execute it:
perl mysqltuner.pl

The script would run multiple checks against your MySQL instance, all checks done by MySQLTuner are documented here.

Also as stated in the official documentation, it is still extremely important for you to fully understand each change you make to a MySQL database server. If you don’t understand portions of the script’s output, or if you don’t understand the recommendations, you should consult a knowledgeable DBA or system administrator that you trust.

As a good practice make sure to always test your changes on staging environments before implementing them on your production database.

On the same note, if you want to have a worry-free MySQL hosting and focus on your application, I would recommend trying out the DigitalOcean Managed Databases:

https://www.digitalocean.com/products/managed-databases-mysql/

This was mini tutorial was posted from bobbyiliev in this question in our community: https://www.digitalocean.com/community/questions/how-to-tweak-mysql-mariadb-configuration-for-increased-performance-and-stability

You can also create a simple bash script to check if MySQL is running and if not to restart it.

#!/bin/bash

# Check if MySQL is running
sudo service mysql status > /dev/null 2>&1

# Restart the MySQL service if it's not running.
if [ $? != 0 ]; then
    sudo service mysql restart
fi

Run this script every 5 minutes using a cron job like this one:

 */5 * * * * /home/user/scripts/monitor.sh > /dev/null 2>&1

Hope that this helps!
Regards,
Alex

Submit an Answer