Mysql cannot allocate memory for the buffer pool 解决方法
2017-11-28 11:56
951 查看
问题出现原因
解决方法
进一步优化
参考文档
发现如下错误日志:
简单解释就是没法为mysql的buffer pool分配128M的内存。
原因很明显了,内存不足呗,查找资料后发现,原来这个参数主要作用是缓存innodb表的索引,数据,插入数据时的缓冲。我的服务器只有1G内存,所以这个参数开始为索引分配缓存的时候把mysql弄崩溃了。
可以看到第四行:
这里显示默认配置是128M,是注释状态,我们只需要把注释去掉,把128改小一点(根据个人情况修改),我改为:
就感觉差不多了。
swap的作用具体这里就不做说明了,简单点说就是可以辅助Mem内存。
直接上代码:
最后添加代码
能看到Mem和swap信息就说明成功了。
最后重启mysql就可以了。
解决方法
进一步优化
参考文档
问题出现原因
昨晚我修改了数据库,为字段添加了”FULLTEXT”索引,结果今天早上发现数据库连不上了,也没法重启,于是查看日志文件:cat /var/log/mysqld.log
发现如下错误日志:
130728 6:50:14 InnoDB: Initializing buffer pool, size = 128.0M InnoDB: mmap(137363456 bytes) failed; errno 12 130728 6:50:14 InnoDB: Completed initialization of buffer pool 130728 6:50:14 InnoDB: Fatal error: cannot allocate memory for the buffer pool
简单解释就是没法为mysql的buffer pool分配128M的内存。
原因很明显了,内存不足呗,查找资料后发现,原来这个参数主要作用是缓存innodb表的索引,数据,插入数据时的缓冲。我的服务器只有1G内存,所以这个参数开始为索引分配缓存的时候把mysql弄崩溃了。
解决方法
mysql的配置都在/ect/mysql.cnf里面(Ubuntu目录有稍微的差别,用whereis my.cnf就能找到了)。
vim /etc/my.cnf
可以看到第四行:
#innodb_buffer_pool_size = 128M
这里显示默认配置是128M,是注释状态,我们只需要把注释去掉,把128改小一点(根据个人情况修改),我改为:
innodb_buffer_pool_size = 50M
就感觉差不多了。
进一步优化
一般出现这种问题的同学,内存肯定都不大,所以我们可以设置swap分区,也就是通常所说的虚拟内存。swap的作用具体这里就不做说明了,简单点说就是可以辅助Mem内存。
直接上代码:
dd if=/dev/zero of=/swapfile bs=1M count=1024 mkswap /swapfile swapon /swapfile
最后添加代码
/swapfile swap swap defaults 0 0到
/etc/fstab文件里面。
free
能看到Mem和swap信息就说明成功了。
最后重启mysql就可以了。
参考文档
http://hongjiang.info/aliyun-vps-mysql-aborting/相关文章推荐
- 解决MySQL : InnoDB: Cannot allocate memory for the buffer pool
- 安装mysql 报Fatal error: cannot allocate memory for the buffer pool
- [MYSQL] ERROR: cannot allocate the memory for the buffer pool
- mysql无法启动——cannot allocate the memory for the buffer pool
- mysql:failed,启动失败,mmap failed-Cannot allocate memory for the buffer pool
- mysql错误日志之cannot allocate the memory for the buffer pool
- MySQL:cannot allocate the memory for the buffer pool
- 【数据库】InnoDB: Fatal error: cannot allocate memory for the buffer pool
- InnoDB: Cannot allocate memory for the buffer pool
- Cannot allocate memory for the buffer pool
- Fatal error: cannot allocate memory for the buffer pool
- Fatal error: cannot allocate memory for the buffer pool
- [ERROR] InnoDB: Cannot allocate memory for the buffer pool
- InnoDB: Cannot allocate memory for the buffer pool
- mysql报错:MySQL server version for the right syntax to use near type=InnoDB的解决方法
- virtual memory exhausted: Cannot allocate memory 解决方法
- php出现[#2002 Cannot log in to the MySQL server]解决方法
- Cannot get a connection, pool error Timeout waiting for idle object解决方法
- live555: The input frame data was too large for our buffer size 解决方法
- mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication的解决方法