最近幫別人做的一個項目機器上面跑MySQL老是隔一段時間就自動停了。剛開始以為是以外停止,也沒注意,就手動再啟動??墒沁^了沒兩天又停止了。
后來仔細查了查mysqld的日志:
2020-05-27T10:15:12.569342Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.17) starting as process 19493
2020-05-27T10:15:14.448256Z 0 [System] [MY-010229] [Server] Starting crash recovery...
2020-05-27T10:15:14.475411Z 0 [System] [MY-010232] [Server] Crash recovery finished.
2020-05-27T10:15:14.691345Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-05-27T10:15:15.677386Z 0 [System] [MY-010931] [Server] /usr/libexec/mysqld: ready for connections. Version: '8.0.17' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution.
2020-05-27T10:15:15.951210Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/lib/mysql/mysqlx.sock' bind-address: '::' port: 33060
2020-05-27T11:26:19.955004Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.17) starting as process 19757
2020-05-27T11:26:20.181302Z 0 [ERROR] [MY-012681] [InnoDB] mmap(137363456 bytes) failed; errno 12
2020-05-27T11:26:20.181360Z 1 [ERROR] [MY-012956] [InnoDB] Cannot allocate memory for the buffer pool
2020-05-27T11:26:20.181379Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
2020-05-27T11:26:20.181401Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2020-05-27T11:26:20.181543Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2020-05-27T11:26:20.183642Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-05-27T11:26:20.184163Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.17) Source distribution.
上面顯示是Cannot allocate memory for the buffer pool
,無法分配內(nèi)存給緩存池。馬上想到是內(nèi)存不足,這臺機器是1GB的內(nèi)存,還跑著 Nginx 和 PHP-FPM 。
使用 top 看了看 mysqld 占用的內(nèi)存達到了48% 。內(nèi)存占用還是蠻高的。
當(dāng)然了升級機器配置是比較好的辦法,但是畢竟經(jīng)費有限。所以我們先給它加個swap交換空間:
dd if=/dev/zero of=/swapfile bs=1M count=2048 mkswap /swapfile swapon /swapfile systemctl restart mysqld
上面我們加了2GB的交換空間給機器。然后重啟 mysqld。再使用top看了看,發(fā)現(xiàn)交換空間漸漸被使用了。
睡了一覺起來一看,mysqld服務(wù)沒有再自動停止,內(nèi)存占用已經(jīng)下降到22%,看了看錯誤日志,也是空的。
嗯,看來還不錯嘛。再觀察個幾天看看,沒問題的話應(yīng)該就好了😎😎😎。
好了,到此這篇關(guān)于MySQL自動停機的問題處理的文章就介紹到這了,更多相關(guān)MySQL自動停機處理內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
標(biāo)簽:白銀 恩施 益陽 定西 寧夏 秦皇島 澳門 杭州
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《MySQL自動停機的問題處理實戰(zhàn)記錄》,本文關(guān)鍵詞 MySQL,自動,停機,的,問題,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。