Help us understand the problem. What is going on with this article?

AmazonAWSで、MySQL がよく落ちる? そんな時はSWAP領域をチェック!

More than 3 years have passed since last update.

Amazon AWSにてt1microサービスを利用していますが、MySQLがよく落ちるんです。


[Note] InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12
[ERROR] InnoDB: Cannot allocate memory for the buffer pool
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting


[root@ip-xxx ~]# free
             total       used       free     shared    buffers     cached
Mem:       1018504     949092      69412      31980      28740     695944
-/+ buffers/cache:     224408     794096
Swap:            0          0          0



[root@ip-xxx ~]# dd if=/dev/zero of=/swapfile bs=1M count=1024

1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 14.8488 s, 72.3 MB/s


[root@ip-xxx ~]# mkswap /swapfile
mkswap: /swapfile: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx


[root@ip-xxx ~]# swapon /swapfile


[root@ip-xxx ~]# free
             total       used       free     shared    buffers     cached
Mem:       1018504     950208      68296      31980      28772     697060
-/+ buffers/cache:     224376     794128
Swap:      1048572          0    1048572


[root@ip-xxx ~]# service mysqld restart
mysqld を停止中:                                           [  OK  ]
mysqld を起動中:                                           [  OK  ]

上記設定のままだと、再起動した時にマウントされないので、 /etc/fstab に以下の1行を追加。

/swapfile    swap       swap    defaults        0   0


Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away