阿里云 mysql 无缘无故挂掉
近期在登录自己博客时,老是报数据库连接失败,然后重启服务器就好了。
但是,重启服务器很耗时间,不方便,不能每次都重启吧
于是远程连接服务器看了一下
原来是数据库服务挂掉了
启动时还报错
于是查看了下错误日志
2016-11-09 08:13:11 12604 [Note] Plugin 'FEDERATED' is disabled.
2016-11-09 08:13:11 12604 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-11-09 08:13:11 12604 [Note] InnoDB: The InnoDB memory heap is disabled
2016-11-09 08:13:11 12604 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-11-09 08:13:11 12604 [Note] InnoDB: Memory barrier is not used
2016-11-09 08:13:11 12604 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-11-09 08:13:11 12604 [Note] InnoDB: Using Linux native AIO
2016-11-09 08:13:11 12604 [Note] InnoDB: Using CPU crc32 instructions
2016-11-09 08:13:11 12604 [Note] InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
2016-11-09 08:13:11 12604 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2016-11-09 08:13:11 12604 [ERROR] Plugin 'InnoDB' init function returned error.
2016-11-09 08:13:11 12604 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-11-09 08:13:11 12604 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-11-09 08:13:11 12604 [ERROR] Aborting
原因是内存不够用了,导致mysql 崩溃
解决办法
修改mysql配置文件
vi /etc/my.cnf
修改如下代码:
[inonodb]
innodb_buffer_pool_size=8MB
把内存改小就好了。
重启MySQL服务
service mysqld restart
参考文章:
InnoDB: mmap(137363456 bytes) failed; errno 12
mysql5.6 无故退出 InnoDB: mmap(137363456 bytes) failed; errno 12
mysql – 启动错误InnoDB: mmap(137363456 bytes) failed; errno 12