InnoDB: Cannot allocate memory for the buffer pool 如何处理?

2017-08-31 21:02:58 +08:00
 MrMike
操作系统是 Centos 6.9, MySQL 版本是 5.6,CPU2 核,内存 2G,网站与数据在同一个服务器上,网站服务器是 apache 2。

my.cnf 配置如下:

[mysqld]

port=3306
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-external-locking
skip-name-resolve
back_log=384
key_buffer_size=16M
max_allowed_packet=4M
thread_stack=256k
sort_buffer_size=6M
read_buffer_size=4M
thread_cache_size=64
query_cache_size=64M
tmp_table_size=256M
max_connections=5000
wait_timeout=60
thread_concurrency=4
skip-networking
innodb_buffer_pool_size=64M
innodb_flush_log_at_trx_commit=2
innodb_log_buffer_size=2M
innodb_thread_concurrency=8
tmp_table_size=64M
read_rnd_buffer_size=16M
lower_case_table_name=1
symbolic-links=0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

一直启动不了 mysql,报错代码:

2017-08-31 21:01:11 11339 [Warning] Buffered warning: Performance schema disabled (reason: init failed).

2017-08-31 21:01:11 11339 [Note] Plugin 'FEDERATED' is disabled.
2017-08-31 21:01:11 11339 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-08-31 21:01:11 11339 [Note] InnoDB: The InnoDB memory heap is disabled
2017-08-31 21:01:11 11339 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-08-31 21:01:11 11339 [Note] InnoDB: Memory barrier is not used
2017-08-31 21:01:11 11339 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-08-31 21:01:11 11339 [Note] InnoDB: Using Linux native AIO
2017-08-31 21:01:11 11339 [Note] InnoDB: Using CPU crc32 instructions
2017-08-31 21:01:11 11339 [Note] InnoDB: Initializing buffer pool, size = 64.0M
InnoDB: mmap(68681728 bytes) failed; errno 12
2017-08-31 21:01:11 11339 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2017-08-31 21:01:11 11339 [ERROR] Plugin 'InnoDB' init function returned error.
2017-08-31 21:01:11 11339 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-08-31 21:01:11 11339 [ERROR] Unknown/unsupported storage engine: InnoDB
2017-08-31 21:01:11 11339 [ERROR] Aborting

2017-08-31 21:01:11 11339 [Note] Binlog end
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'partition'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_METRICS'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_CMPMEM'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_CMP'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_LOCKS'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'INNODB_TRX'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'ARCHIVE'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'BLACKHOLE'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'CSV'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'MEMORY'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'MRG_MYISAM'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'MyISAM'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'sha256_password'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'mysql_old_password'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'mysql_native_password'
2017-08-31 21:01:11 11339 [Note] Shutting down plugin 'binlog'
2017-08-31 21:01:11 11339 [Note] /usr/sbin/mysqld: Shutdown complete

按照网上的类似方法,一直减少 innodb_buffer_pool_size=64M,还是不能启动。。
4957 次点击
所在节点    MySQL
6 条回复
ToughGuy
2017-08-31 22:10:35 +08:00
你这配置文件, 不懂就别瞎调整,xxx_buffer_size 哪有调那么大的。

你用默认配置文件就好, 然后适当的加大一下 innodb_buffer_pool_size, 如果还不能启动的话检查系统是不是被你改过了(内核参数)。

echo > /etc/sysctl.conf && reboot

然后再试试。
0ZXYDDu796nVCFxq
2017-08-31 22:17:10 +08:00
MySQL 有 mini 配置模板,先把配置重置为官方的 mini 配置再看
snnn
2017-08-31 22:37:53 +08:00
把数据目录下所有文件全删了。重新初始化
MrMike
2017-08-31 22:53:38 +08:00
@ToughGuy
@gstqc
@snnn 谢了,我还原了默认的版本 my.cnf 。然后设置了 swap,就可以了。
snnn
2017-08-31 23:18:54 +08:00
@MrMike 你要明白为什么。。。。。。
你出错是因为你改了某个配置的值。而且你肯定应该改这个值
MrMike
2017-08-31 23:37:05 +08:00
@snnn 并不是我改过某个值,我安装好后,就报错了。后来修改的内容,也都是通过网络查询的,只是没有解决到问题。谢谢你的回复。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/387275

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX