MySQL入れる

番外編 - MySQLもついでに入れる

参考にしたのは以下の記事

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04-ja

インストール時に以下のエラー

Sub-process /usr/bin/dpkg returned an error code (1)

https://www.nalabo.net/blog/2022/04/06/1289

これでセキュアインストールをやろうとするが、今度は別のエラー。

Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

対処はこちら

https://qiita.com/ohnomasaya2404/items/393fa397f73975d9e0c2

で、systemctl start mysqlしようとすると今度は

job for mysql.service failed because a fatal signal was delivered to the control process.
See "systemctl status mysql.service" and "journalctl -xe" for details.

journalctl -xe

すると、以下のログが残っている。

Jan 18 20:22:52 ik1-340-30076 kernel: [ 333337]   114 333337   189614    71722   843776        0             0 mysqld
Jan 18 20:22:52 ik1-340-30076 kernel: oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/system.slice/mysql.service,task=mysqld,pid=333337,uid=114
Jan 18 20:22:52 ik1-340-30076 kernel: Out of memory: Killed process 333337 (mysqld) total-vm:758456kB, anon-rss:286888kB, file-rss:0kB, shmem-rss:0kB, UID:114 pgtables:824kB oom_score_adj:0
Jan 18 20:22:52 ik1-340-30076 systemd[1]: mysql.service: Main process exited, code=killed, status=9/KILL
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit mysql.service has exited.
--
-- The process' exit code is 'killed' and its exit status is 9.
Jan 18 20:22:52 ik1-340-30076 systemd[1]: mysql.service: Failed with result 'signal'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit mysql.service has entered the 'failed' state with result 'signal'.
Jan 18 20:22:52 ik1-340-30076 systemd[1]: Failed to start MySQL Community Server.
-- Subject: A start job for unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mysql.service has finished with a failure.
--
-- The job identifier is 82277 and the job result is failed.
Jan 18 20:22:52 ik1-340-30076 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Automatic restarting of the unit mysql.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Jan 18 20:22:52 ik1-340-30076 systemd[1]: Stopped MySQL Community Server.
-- Subject: A stop job for unit mysql.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A stop job for unit mysql.service has finished.
--
-- The job identifier is 82352 and the job result is done.
Jan 18 20:22:52 ik1-340-30076 systemd[1]: mysql.service: Start request repeated too quickly.
Jan 18 20:22:52 ik1-340-30076 systemd[1]: mysql.service: Failed with result 'signal'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit mysql.service has entered the 'failed' state with result 'signal'.
Jan 18 20:22:52 ik1-340-30076 systemd[1]: Failed to start MySQL Community Server.
-- Subject: A start job for unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mysql.service has finished with a failure.
--
-- The job identifier is 82352 and the job result is failed.
Jan 18 20:23:00 ik1-340-30076 sudo[333350]:  mconfjp : TTY=pts/0 ; PWD=/home/mconfjp ; USER=root ; COMMAND=/usr/bin/journalctl -xe

気になるところをいくつか上げていくと、

  • oom-kill
    • メモリの状況を監視して、メモリ足りなくなってきたな〜〜ってなったらプロセスを殺していくやつらしい。
    • ただ、topコマンド打ってみると、メモリの半分以上が使われてない。。