Most of us use EC2 micro instances for prototyping and running small servers. If you use MySQL on an EC2 machine, you may experience the MySQL server automatically shut down with the /var/log/mysql/error.log file reading as below:
140516 10:54:24 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
140516 10:54:24 InnoDB: Completed initialization of buffer pool
140516 10:54:24 InnoDB: Fatal error: cannot allocate memory for the buffer pool
140516 10:54:24 [ERROR] Plugin 'InnoDB' init function returned error.
140516 10:54:24 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140516 10:54:24 [ERROR] Unknown/unsupported storage engine: InnoDB
140516 10:54:24 [ERROR] Aborting
The cause of the frequent server shutdowns is the lack of available memory for allocation to InnoDB. EC2 micro instances have only 613MB of memory and no swap space. The easiest method to recover from the above error is to create a swap space for your machine.
To create your swap space, execute the following code as root user:
dd if=/dev/zero of=/swapfile bs=1M count=1024
To create the swap spaces on server start, add the following line to
/swapfile swap swap defaults 0 0
After creating the swap space, you should be able to start your MySQL service again.