2018.10.05
東京リージョンでAmazon Linux 2をt2.nanoインスタンスで起動して、Itamaeを使ってRuby on Railsの環境を自動構築しようとしたら、MySQL Serverを立ち上げるところでエラーが発生した。
ERROR : stdout | Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
ERROR : Command `systemctl start mysqld` failed. (exit status: 1)
ERROR : service[mysqld] Failed.
/etc/my.cnf
を編集してMySQLサーバーのメモリの確保を抑えたら無事MySQL Serverを起動できた。
[mysqld] # ← [mysqld]のセクションに
table_definition_cache=400 # ← この行を追加した
エラーにある指示通りsystemctl status mysqld.service
とjournalctl -xe
を実行して状況を確認してみた。
Oct 05 18:18:44 ip-XX-X-X-XXX.ap-northeast-1.compute.internal kernel: Out of memory: Kill process 6775 (mysqld) score 845 or sacrifice child
Oct 05 18:18:44 ip-XX-X-X-XXX.ap-northeast-1.compute.internal kernel: Killed process 6775 (mysqld) total-vm:464120kB, anon-rss:415968kB, file-rss:0kB, shmem-rss:0kB
Oct 05 18:18:44 ip-XX-X-X-XXX.ap-northeast-1.compute.internal mysqld[6543]: /usr/bin/mysqld_safe: line 183: 6775 Killed nohup /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=
Oct 05 18:18:44 ip-XX-X-X-XXX.ap-northeast-1.compute.internal mysqld[6543]: MySQL Daemon failed to start.
Oct 05 18:18:44 ip-XX-X-X-XXX.ap-northeast-1.compute.internal mysqld[6543]: Starting mysqld: [FAILED]
Oct 05 18:18:44 ip-XX-X-X-XXX.ap-northeast-1.compute.internal systemd[1]: mysqld.service: control process exited, code=exited status=1
Oct 05 18:18:44 ip-XX-X-X-XXX.ap-northeast-1.compute.internal systemd[1]: Failed to start SYSV: MySQL database server..
Out of memory
だそうだ。t2.nanoインスタンスはメモリが500MBしかないから節約しなければならない。
MySQL Serverの設定を変更する。
[mysqld] # ← [mysqld]のセクションに
table_definition_cache=400 # ← この行を追加した
改めてMySQL Serverを起動する。
$ sudo systemctl start mysqld
無事起動できた。