1. 程式人生 > >centos Cannot allocate memory for the buffer pool

centos Cannot allocate memory for the buffer pool

compress instr suse ocean crc ret imp 參數設置 git

mysql 無法啟動 ,查看日誌:

17-10-01T15:37:27.401599Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-10-01T15:37:27.403209Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.19) starting as process 5504 ...
2017-10-01T15:37
:27.406004Z 0 [Note] InnoDB: PUNCH HOLE support available 2017-10-01T15:37:27.406028Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2017-10-01T15:37:27.406032Z 0 [Note] InnoDB: Uses event mutexes 2017-10-01T15:37:27.406035Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2017
-10-01T15:37:27.406038Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2017-10-01T15:37:27.406041Z 0 [Note] InnoDB: Using Linux native AIO 2017-10-01T15:37:27.406290Z 0 [Note] InnoDB: Number of pools: 1 2017-10-01T15:37:27.406379Z 0 [Note] InnoDB: Using CPU crc32 instructions 2017-10-01T15:37:27.407775Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1
, chunk size = 128M 2017-10-01T15:37:27.407813Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12 2017-10-01T15:37:27.407819Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool 2017-10-01T15:37:27.407824Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2017-10-01T15:37:27.407829Z 0 [ERROR] Plugin InnoDB init function returned error. 2017-10-01T15:37:27.407832Z 0 [ERROR] Plugin InnoDB registration as a STORAGE ENGINE failed. 2017-10-01T15:37:27.407834Z 0 [ERROR] Failed to initialize plugins. 2017-10-01T15:37:27.407836Z 0 [ERROR] Aborting 2017-10-01T15:37:27.407852Z 0 [Note] Binlog end 2017-10-01T15:37:27.407890Z 0 [Note] Shutting down plugin CSV 2017-10-01T15:37:27.408059Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

定位到最後幾行,果然有一個FATAL ERROR:Cannot allocate memory for the buffer pool,看來應該是mariadb沒有配置好,php程序訪問量稍微大一些,分配給mariadb的內存就滿了,然後就鎖死了,mysql –u root –p竟然也打不開,看來確實是mariadb daemon掛掉了…

Innodb 存儲引擎的緩存機制和 MyISAM 的最大區別就在於 Innodb 不僅僅緩存索引,同時還會緩存實際的數據。所以,完全相同的數據庫,使用 Innodb 存儲引擎可以使用更多的內存來緩存數據庫相關的信息,當然前提是要有足夠的物理內存。innodb_buffer_pool_size 參數用來設置 Innodb 最主要的 Buffer(Innodb_Buffer_Pool)的大小,也 就是緩存用戶表及索引數據的最主要緩存空間,對 Innodb 整體性能影響也最大。這個參數設置成內存的50%-80%,當然具體要結合實際情況而定,考慮別的存儲引擎占用的內存,考慮服務器是不是還提供其他服務等等…看來,我的機器之所以宕掉的原因是,系統默認的內存:

default innodb_buffer_pool_size

innodb_buffer_pool_size=50M

再次啟動

sudo systemctl start mysqld

恢復正常

關閉suse:

查看SELinux狀態:

1、/usr/sbin/sestatus -v ##如果SELinux status參數為enabled即為開啟狀態

SELinux status: enabled

2、getenforce ##也可以用這個命令檢查

關閉SELinux:

1、臨時關閉(不用重啟機器):

setenforce 0 ##設置SELinux 成為permissive模式

##setenforce 1 設置SELinux 成為enforcing模式

2、修改配置文件需要重啟機器:

修改/etc/selinux/config 文件

將SELINUX=enforcing改為SELINUX=disabled

重啟機器即可

參考:https://blog.feehi.com/linux/132.html

mysql安裝:

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-centos-7

centos Cannot allocate memory for the buffer pool