I set up a VPS on Amazon some days ago. I installed LAMP server and then uploaded some sites there. Everything was working fine until yesterday I noticed the sites showing database connection errors. I checked the error log in /var/log/mysql/ and it seems that there are some memory problems. You can see the last records from the error log here: https://paste.ubuntu.com/23533774/

I read somewhere that "Cannot allocate memory for the buffer pool" indicates that this is memory problem and a solution to it would be adding a swap file.

What I wanted to know is if I should increase memory ram for the VPS or if I should add this swap file. Or perhaps there's another solution I don't know about.

Additional info: - Memory Ram available now is 1GB - There's about 2 html sites, 2 wordpress sites, 1 joomla site and 3 other php sites. Possible couple more sites to be added. - This is the first time I set up a server

Thanks for the help in advance.


According to https://stackoverflow.com/questions/10284532/amazon-ec2-mysql-aborting-start-because-innodb-mmap-x-bytes-failed-errno-12 you need to add a swap page.

You can follow this to setup the swap page:


According to this site (I'm just copying here)

Steps below show how to make a swap space for your Micro instance. I assume you have AWS Account with a Micro instance running.

  1. Run dd if=/dev/zero of=/swapfile bs=1M count=1024
  2. Run mkswap /swapfile
  3. Run swapon /swapfile
  4. Add this line /swapfile swap swap defaults 0 0 to /etc/fstab

Step 4 is needed if you would like to automatically enable swap file after each reboot.

Some useful command related to SWAP space:

$ swapon -s   
$ free -k

$ swapoff -a
$ swapon  -a


  1. http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/
  2. http://cloudstory.in/2012/02/getting-the-best-out-of-amazon-ec2-micro-instances/
  3. http://cloudstory.in/2012/02/adding-swap-space-to-amazon-ec2-linux-micro-instance-to-increase-the-performance/
  4. http://aws.amazon.com/ec2/instance-types/
  • I assume the best option is to add the swap file then. I did as you mentioned and things are working fine again. Thanks for the help. – Alex Dec 3 '16 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.