我有MySQL的错误日志,知道吗? 网站运行一段时间后,我得到MySQL完全关闭几个小时后。
140919 10:48:27 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
140919 10:48:27 [Note] Plugin 'FEDERATED' is disabled.
140919 10:48:27 InnoDB: The InnoDB memory heap is disabled
140919 10:48:27 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140919 10:48:27 InnoDB: Compressed tables use zlib 1.2.3.4
140919 10:48:28 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
140919 10:48:28 InnoDB: Completed initialization of buffer pool
140919 10:48:28 InnoDB: Fatal error: cannot allocate memory for the buffer pool
140919 10:48:28 [ERROR] Plugin 'InnoDB' init function returned error.
140919 10:48:28 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140919 10:48:28 [ERROR] Unknown/unsupported storage engine: InnoDB
140919 10:48:28 [ERROR] Aborting
140919 10:48:28 [Note] /usr/sbin/mysqld: Shutdown complete
140919 10:48:28 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
140919 10:48:28 [Note] Plugin 'FEDERATED' is disabled.
140919 10:48:28 InnoDB: The InnoDB memory heap is disabled
140919 10:48:28 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140919 10:48:28 InnoDB: Compressed tables use zlib 1.2.3.4
140919 10:48:28 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
140919 10:48:28 InnoDB: Completed initialization of buffer pool
140919 10:48:28 InnoDB: Fatal error: cannot allocate memory for the buffer pool
140919 10:48:28 [ERROR] Plugin 'InnoDB' init function returned error.
140919 10:48:28 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140919 10:48:28 [ERROR] Unknown/unsupported storage engine: InnoDB
140919 10:48:28 [ERROR] Aborting
140919 10:48:28 [Note] /usr/sbin/mysqld: Shutdown complete
解决方案不是空间太大,问题是Apache web服务器不是mysql,实际上需要减小innodb缓冲池的大小
mysql进程在一开始就使用这个缓冲区,因此当Apache需要更多资源时,内核将从服务中清除RAM,这意味着停止mysql而不是崩溃服务器。
如果不想更改为ngnx或httplight,还可以添加CRON来检查db状态并重新启动它。
TLDR
Mysql无法重新启动,因为内存不足,请检查是否配置了适当的交换文件。
帮不上忙?如果这不是你的问题,更适合继续研究的问题是:
背景
我在EC2上建立的第一个系统就遇到了这个问题,其特点是托管在那里的wordpress站点有时会出现“建立数据库连接时出错”的情况。
日志显示的错误与OP发布的相同。我读取的错误(删除时间戳)是:
InnoDB: Fatal error: cannot allocate memory for the buffer pool
[ERROR] Plugin 'InnoDB' init function returned error. [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. [ERROR] Unknown/unsupported storage engine: InnoDB [ERROR] Aborting
[Note] /usr/sbin/mysqld: Shutdown complete
检查
/var/log/syslog
并搜索mysql产生:注意:如果错误发生在cron轮换日志之前,则可能需要对存档日志进行压缩和搜索。
解决方案
在我的例子中,根本的问题是我忽略了配置交换文件。
您可以通过运行
free -m
检查是否配置了一个。total used free shared buffers cached Mem: 604340 587364 16976 0 29260 72280 -/+ buffers/cache: 485824 118516 Swap: 0 0 0
在上面的示例中,Swap:0表示没有swapfile。
关于设置一个的教程:
注意,越大未必越好!来自Ubuntu guide:
关于这里的其他答案
The InnoDB memory heap is disabled
感谢:Ruben Schade comment
[Note] Plugin 'FEDERATED' is disabled.
见:https://stackoverflow.com/a/16470822/2586761
我发现这个答案增加了讨论:https://www.digitalocean.com/community/questions/mysql-server-keeps-stopping-unexpectedly?answer=26021
简而言之,除了将innodb_buffer_pool_size设置为合理的64M大小之外,您还可能需要修改/etc/apache2/mods enabled/mpm_prefork.conf以减少apache启动的连接数
相关问题 更多 >
编程相关推荐