線上的一套MySQL 5.6的從庫,因為OOM而導(dǎo)致數(shù)據(jù)庫重啟。
創(chuàng)新互聯(lián)公司是一家專業(yè)從事成都網(wǎng)站設(shè)計、網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計的品牌網(wǎng)絡(luò)公司。如今是成都地區(qū)具影響力的網(wǎng)站設(shè)計公司,作為專業(yè)的成都網(wǎng)站建設(shè)公司,創(chuàng)新互聯(lián)公司依托強(qiáng)大的技術(shù)實力、以及多年的網(wǎng)站運營經(jīng)驗,為您提供專業(yè)的成都網(wǎng)站建設(shè)、營銷型網(wǎng)站建設(shè)及網(wǎng)站設(shè)計開發(fā)服務(wù)!# tail -50 /var/log/messages Nov 13 16:00:40 app-push-db2 kernel: Out of memory: Kill process 26121 (mysqld) score 957 or sacrifice child Nov 13 16:00:40 app-push-db2 kernel: Killed process 26121 (mysqld) total-vm:18804176kB, anon-rss:15541596kB, file-rss:0kB, shmem-rss:0kB
報錯原因:
這臺實例所在的服務(wù)器上面部署了單實例MySQL,物理內(nèi)存為16G,分配給數(shù)據(jù)庫的緩存innodb_fuffer_pool_size為12G。
# free -g total used free shared buff/cache available Mem: 15 10 0 0 5 4 Swap: 0 0 0
為了提高性能,這臺實例關(guān)閉了磁盤的swap交換。
# cat /etc/rc.local #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In contrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure # that this script will be executed during boot. touch /var/lock/subsys/local swapoff -a
當(dāng)客戶端連接多的時候,導(dǎo)致內(nèi)存資源耗盡。
解決方法:
將innodb_buffer_pool_size調(diào)整為10G,預(yù)留出一些內(nèi)存給操作系統(tǒng)和客戶端連接。
重啟數(shù)據(jù)庫,使參數(shù)生效。
# grep innodb_buffer_pool /etc/my.cnf innodb_buffer_pool_size=10G