Mysql資料庫經常停止並且無法重新啟動

Mysql資料庫經常停止並且無法重新啟動

伺服器:Linode專用4G Ubuntu 18.04,Webmin + Virtualmin

mysql伺服器時不時地停止並重新啟動失敗。這是我能找到的日誌:

Apr 11 20:54:57 bamboo kernel: [ 2082.915857] [ 7664]   112  7664   406072    46295   745472        3             0 mysqld
Apr 11 20:54:57 bamboo kernel: [ 2082.915859] [ 7701]     0  7701   129687      307   679936     1435             0 apache2
Apr 11 20:54:57 bamboo kernel: [ 2082.915860] [ 7702]     0  7702   129683      253   667648     1487             0 apache2
Apr 11 20:54:57 bamboo kernel: [ 2082.915861] Out of memory: Kill process 7664 (mysqld) score 40 or sacrifice child
Apr 11 20:54:57 bamboo kernel: [ 2082.919284] Killed process 7664 (mysqld) total-vm:1624288kB, anon-rss:185180kB, file-rss:0kB, shmem-rss:0kB
Apr 11 20:54:57 bamboo kernel: [ 2082.941447] oom_reaper: reaped process 7664 (mysqld), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
Apr 11 20:54:57 bamboo systemd[1]: mysql.service: Main process exited, code=killed, status=9/KILL
Apr 11 20:54:57 bamboo systemd[1]: mysql.service: Failed with result 'signal'.
Apr 11 20:54:57 bamboo systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Apr 11 20:54:57 bamboo systemd[1]: mysql.service: Scheduled restart job, restart counter is at 4.
Apr 11 20:54:57 bamboo systemd[1]: Stopped MySQL Community Server.

..........

Apr 11 14:02:53 bamboo systemd[1]: mysql.service: Scheduled restart job, restart counter is at 4.
Apr 11 14:02:53 bamboo systemd[1]: Stopped MySQL Community Server.
Apr 11 14:02:53 bamboo systemd[1]: Starting MySQL Community Server...
Apr 11 14:02:53 bamboo mysqld[4345]: Initialization of mysqld failed: 0
Apr 11 14:02:53 bamboo systemd[1]: mysql.service: Control process exited, code=exited status=1
Apr 11 14:02:53 bamboo systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 11 14:02:53 bamboo systemd[1]: Failed to start MySQL Community Server.
Apr 11 14:02:53 bamboo systemd[1]: mysql.service: Service hold-off time over, scheduling restart.

看來是記憶體問題。但我在這台伺服器上託管了一些非常小的wordpress網站,它們不可能用完記憶體。

伺服器圖: 在此輸入影像描述

您可以看到 CPU 使用率出現峰值,這是在 mysql 資料庫停止時發生的。

當時我沒有做任何特別的事情,所以我很難重現問題並觀察可能的原因。我想要調查這個問題我需要更深入地研究日誌,但這完全超出了我的知識範圍。

有人可以闡明如何找到可能的原因嗎?

答案1

記憶體不足:終止進程oom_reaper……這明顯是記憶體問題。

MySQL 停止後,結果是什麼:free -h

嘗試重新啟動 MySQL 並檢查htop其他控制台,以即時監控進程、RAM、CPU...

在 MySQL 控制台中檢查 INNODB 緩衝區大小,也許它超過了您的實體可用記憶體:

show global variables like 'innodb_buffer_pool_size';

你有SWAP分割區嗎?

對於Wordpress方面,有Wordpress網站,還有Wordpress網站......你有一些外掛嗎?有些可能是資料庫密集型的(或只是沒有最佳化)。

相關內容