Mysqld Service Stops Once a Day on Ec2 Server

Amazon EC2 MySQL Failed to Start

I fixed this by restarting my EC2 instance.

Amazon EC2, mysql aborting start because InnoDB: mmap (x bytes) failed; errno 12

I met the same problem when I tried to run a wordpress on my micro instance without RDS.

Adding a Swap page solved the problem for me.

You can follow steps below to setup the swap space.

If it still doesn't work for you, consider using the RDS service.

===============================================

I copied the content of the blog for the record. Credit goes to the blog author pmoubed:

Amazon EC2 Micro Instance Swap Space - Linux

I have a Amazon EC2 Linux Micro instance. Since Micro instances have only 613MB of memory, MySQL crashed every now and then. After a long search about MySQL, Micro Instance and Memory Managment I found out there is no default SWAP space for Micro instance. So if you want to avoid the crash you may need to setup a swap space for your micro instance. Actually performance wise is better to enable swap.

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

References:

  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/

Why does AWS EC2 instance authentication keeps stop working (session maybe)?

If an issue is resolved by the restart of server/EC2-instance, then most likely you have memory/CPU related problems in your application.

You can do the following to nail the issue

  1. Trace the cloudwatch statistics for your EC2 instance for CPU and memory
  2. Set up another environment for load testing your application
  3. Generate load script to simulate the scenario leading to the problem
  4. Run a code profiler to investigate the problematic code
  5. Fix problems, run the load again to verify your changes
  6. Apply the changes in prod and hope your application rocks in production afterward

EDIT : As suggested by @Boinst, as in interm solution you can schedule restart of EC2 instance, while you find the root cause. One of the ways to do that can be to use AWS CLI

aws ec2 reboot-instances --instance-ids yourInstanceId

you can add a cronjob/scheduled task a machine setup with AWS CLI.

the MySQL service on local computer started and then stopped

After installing it by mysqld --install. Try this mysqld --initialize. We got the same problem but it's now working.

AWS stop / start make Wordpress unresponsive

Cause :
I noticed that in firebub the CSS and Javascript was loaded from the prior IP (before the stop aws instance).
Indeed AWS change my IP when I stop / start the instance.
But I didn't know that WordPress keep the website IP in the database and use it to load the css and js files.
So I just updated the IP and it was working again.

Fix :
table to update :
update wp_options
set option_value =
where option_name = 'siteurl';



Related Topics



Leave a reply



Submit