読者です 読者をやめる 読者になる 読者になる

awsでmysqlが突然起動しなくなった件

awsmysqlが突然落ちて再度起動しようとしたときのエラー

160731 16:54:25 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2016-07-31 16:54:25 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-07-31 16:54:25 0 [Note] /usr/sbin/mysqld (mysqld 5.6.31-log) starting as process 12918 ...
2016-07-31 16:54:25 12918 [Note] Plugin 'FEDERATED' is disabled.
2016-07-31 16:54:25 12918 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-07-31 16:54:25 12918 [Note] InnoDB: The InnoDB memory heap is disabled
2016-07-31 16:54:25 12918 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-07-31 16:54:25 12918 [Note] InnoDB: Memory barrier is not used
2016-07-31 16:54:25 12918 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-07-31 16:54:25 12918 [Note] InnoDB: Using Linux native AIO
2016-07-31 16:54:25 12918 [Note] InnoDB: Using CPU crc32 instructions
2016-07-31 16:54:25 12918 [Note] InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
2016-07-31 16:54:25 12918 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2016-07-31 16:54:25 12918 [ERROR] Plugin 'InnoDB' init function returned error.
2016-07-31 16:54:25 12918 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-07-31 16:54:25 12918 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-07-31 16:54:25 12918 [ERROR] Aborting

2016-07-31 16:54:25 12918 [Note] Binlog end
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'partition'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'ARCHIVE'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_METRICS'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_CMPMEM'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_CMP'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_LOCKS'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'INNODB_TRX'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'BLACKHOLE'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'CSV'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'MyISAM'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'MEMORY'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'MRG_MYISAM'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'sha256_password'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'mysql_old_password'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'mysql_native_password'
2016-07-31 16:54:25 12918 [Note] Shutting down plugin 'binlog'
2016-07-31 16:54:25 12918 [Note] /usr/sbin/mysqld: Shutdown complete

160731 16:54:25 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

どうやらスワップ領域を作っていなかったのが原因ぽい。freeコマンドでスワップ領域を確認。

# free
             total       used       free     shared    buffers     cached
Mem:       1018336     526272     492064        244       9144      61372
-/+ buffers/cache:     455756     562580
Swap:            0          0          0

以下のコマンドでスワップ領域を作成すればok

dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile

参考サイト
http://ultrah.zura.org/?p=10137
Vagrant+VirtualBox+CentOS環境でMySQL5.6が起動しない場合の対処法 - 憂鬱な世界にネコパンチ!
AmazonAWSで、MySQL がよく落ちる? そんな時はSWAP領域をチェック! - Qiita