[ERROR] InnoDB: Cannot allocate memory for the buffer pool

本文记录了一次MySQL启动失败的问题排查及解决过程。由于InnoDB内存池分配失败导致MySQL无法正常启动,通过调整innodb_buffer_pool_size配置并设置swap分区解决了问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

160913 01:54:42 mysqld_safe Starting mysqld daemon with databases from /data/mysqldb
2016-09-13 01:54:46 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.31-log) starting as process 14386 ...
2016-09-13 01:54:47 14386 [Warning] option 'innodb-buffer-pool-instances': signed value -1 adjusted to 0
/usr/local/mysql/bin/mysqld: Table 'mysql.plugin' doesn't exist
2016-09-13 01:54:47 14386 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2016-09-13 01:54:47 14386 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-09-13 01:54:47 14386 [Note] InnoDB: The InnoDB memory heap is disabled
2016-09-13 01:54:47 14386 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-09-13 01:54:47 14386 [Note] InnoDB: Memory barrier is not used
2016-09-13 01:54:47 14386 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-09-13 01:54:47 14386 [Note] InnoDB: Using CPU crc32 instructions
2016-09-13 01:54:47 14386 [Note] InnoDB: Initializing buffer pool, size = 1.0G
InnoDB: mmap(137363456 bytes) failed; errno 12
2016-09-13 01:54:47 14386 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2016-09-13 01:54:47 14386 [ERROR] Plugin 'InnoDB' init function returned error.
2016-09-13 01:54:47 14386 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-09-13 01:54:47 14386 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-09-13 01:54:47 14386 [ERROR] Aborting

2016-09-13 01:54:47 14386 [Note] Binlog end
2016-09-13 01:54:47 14386 [Note] Shutting down plugin 'partition'
2016-09-13 01:54:47 14386 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2016-09-13 01:54:47 14386 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2016-09-13 01:54:47 14386 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2016-09-13 01:54:47 14386 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2016-09-13 01:54:47 14386 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2016-09-13 01:54:47 14386 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'

说是缓存分配失败那就看一下缓存呗

[root@ip-172-31-27-132 log]# free -m
              total        used        free      shared  buff/cache   available
Mem:            991          70         787          12         133         778
Swap:             0           0           0

发现自己根本就没有配置缓存。。这个就尴尬了,下面有解决方法

 

解决方法:
1) 在 /etc/mysql/my.cnf 的 mysqld 下增加下面一句:
innodb_buffer_pool_size = 64M(64M每个人配置文件不一样,自己看着改)
还要设置一下swap分区,因为我的vps是没有swap分区的,通过fdisk -l 和 1mount 看不到swap的信息,需要手动添加一下。
2) 添加swap分区的步骤:
2.1) dd if=/dev/zero of=/swapfile bs=1M count=1024
2.2) mkswap /swapfile
2.3) swapon /swapfile
2.4) 添加这行: /swapfile swap swap defaults 0 0 到 /etc/fstab
目前已经设置了swap分区,并重启了mysql,后续观察一下看看还会不会出现吧。
参考:http://stackoverflow.com/questions/10284532/amazon-ec2-mysql-aborting-start-because-innodb-mmap-x-bytes-failed-errno-12

sudo cat /usr/local/mysql/data/VM-16-9-centos.err 2025-03-20T02:00:15.739959Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2025-03-20T02:00:15.740032Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled 2025-03-20T02:00:15.740057Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.36) starting as process 813856 ... 2025-03-20T02:00:15.747664Z 0 [Note] InnoDB: PUNCH HOLE support available 2025-03-20T02:00:15.747684Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2025-03-20T02:00:15.747688Z 0 [Note] InnoDB: Uses event mutexes 2025-03-20T02:00:15.747691Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier 2025-03-20T02:00:15.747695Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 2025-03-20T02:00:15.747698Z 0 [Note] InnoDB: Using Linux native AIO 2025-03-20T02:00:15.747921Z 0 [Note] InnoDB: Number of pools: 1 2025-03-20T02:00:15.748013Z 0 [Note] InnoDB: Using CPU crc32 instructions 2025-03-20T02:00:15.749664Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2025-03-20T02:00:15.758255Z 0 [Note] InnoDB: Completed initialization of buffer pool 2025-03-20T02:00:15.760782Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2025-03-20T02:00:15.772580Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2025-03-20T02:00:15.783164Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2025-03-20T02:00:15.783219Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2025-03-20T02:00:15.815854Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2025-03-20T02:00:15.816646Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
最新发布
03-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值