Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I have set up a micro instance server on EC2 based

MySQL server fails frequently and for the third time, MySQL server is gone. The logs only show

120423 09:13:38 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

120423 09:14:27 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

120423  9:14:27 [Note] Plugin 'FEDERATED' is disabled.

120423  9:14:27 InnoDB: The InnoDB memory heap is disabled

120423  9:14:27 InnoDB: Mutexes and rw_locks use GCC atomic builtins

120423  9:14:27 InnoDB: Compressed tables use zlib 1.2.3

120423  9:14:27 InnoDB: Using Linux native AIO

120423  9:14:27 InnoDB: Initializing buffer pool, size = 512.0M

InnoDB: mmap(549453824 bytes) failed; errno 12

120423  9:14:27 InnoDB: Completed initialization of buffer pool

120423  9:14:27 InnoDB: Fatal error: cannot allocate memory for the buffer pool

120423  9:14:27 [ERROR] Plugin 'InnoDB' init function returned error.

120423  9:14:27 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

120423  9:14:27 [ERROR] Unknown/unsupported storage engine: InnoDB

120423  9:14:27 [ERROR] Aborting

What is really failed; errno 12? And how could I give more space/memory or whatever needed to make this fixed.

I fix this each time by rebooting the whole system and deleting all logs and restart the MySQL server. But I know something is wrong with my configuration.

Also, my `my.cnf' is like below :

[mysqld]

# Settings user and group are ignored when systemd is used.

# If you need to run mysqld under different user or group,

# customize your systemd unit file for mysqld according to the

# instructions in http://fedoraproject.org/wiki/Systemd

# max_allowed_packet=500M

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0


 

innodb_buffer_pool_size         = 512M


 

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

1 Answer

0 votes
by (44.4k points)

A default SWAP space for micro instance is not available. So, you have to set up a swap space for your micro instance to avoid crashes. Micro instances have only 613MB of memory, so MySQL might crash quite often. Setting up a swap space can provide better performance.

Follow the below steps to create a swap space for your micro instance. First, create an AWS account and run a Micro instance to start with.

Follow these steps to create a swap space for your running micros instance. First, create an AWS account and run a micro instance to begin with.

  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

If you want to automatically enable swap file after every reboot, then you can do the fourth step.

Few commands related to SWAP space:

$ swapon -s   

$ free -k

$ swapoff -a

$ swapon  -a

Related questions

0 votes
1 answer
asked Jul 31, 2019 in AWS by yuvraj (19.1k points)
Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...