我有来自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
答案 0 :(得分:53)
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 会产生:
Out of memory: Kill process 15452 (mysqld) score 93 or sacrifice child
Killed process 15452 (mysqld) total-vm:888672kB, anon-rss:56252kB, file-rss:0kB
init: mysql main process (15452) killed by KILL signal
init: mysql main process ended, respawning
type=1400 audit(1443812767.391:30): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=21984 comm="apparmor_parser"
init: mysql main process (21996) terminated with status 1
init: mysql main process ended, respawning
init: mysql post-start process (21997) terminated with status 1
<repeated>
注意:如果在cron轮换日志之前发生错误,您可能需要进行gunzip并搜索存档日志。
在我的情况下,潜在的问题是我忽略了配置交换文件。
您可以通过运行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表示没有交换文件。
设置一个教程:
请注意,更大不一定更好!来自Ubuntu guide:
“收益递减”意味着如果您需要更多的交换空间而不是RAM大小的两倍,您最好添加更多RAM,因为硬盘驱动器(HDD)访问速度比RAM慢约10 3访问,所以需要1秒的东西,突然需要超过15分钟!在快速固态硬盘(SSD)上还有一分钟......
The InnoDB memory heap is disabled
这不是一个真正的错误,只是表明InnoDB正在使用系统的内部内存分配器而不是它自己的内存。默认值为yes / 1,可以接受生产。
根据文档,这个命令已被弃用,将在5.6以上的MySQL版本中删除(我假设MariaDB):
http://dev.mysql.com/doc/refman/5.6/en/innodb-performance-use_sys_malloc.html
[Note] Plugin 'FEDERATED' is disabled.
关于FEDERATED禁用的消息不是错误。它只是意味着FEDERATED引擎对你的mysql服务器不开启。它默认不使用。如果您不需要,请不要关心此消息。
答案 1 :(得分:3)
解决方案不是更多空间,问题是Apache Web服务器不是mysql,实际上你需要减少innodb-buffer-pool-size
这个缓冲区一开始就被mysql进程使用,所以当Apache需要更多资源时,内核将从服务中清除RAM,这意味着停止mysql而不是崩溃服务器。
如果您不想更改为ngnx或httplight,还会添加一个CRON来检查db状态并重新启动它。
答案 2 :(得分:2)
我发现这个答案增加了讨论: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启动的连接数;
{'Season': array(['2011-12', '2010-11', '2009-10', '2008-09', '2007-08', '2006-07'],
dtype=object), 'Matches Played': array([38, 38, 38, 38, 38, 38], dtype=int64), 'Wins': array([28, 23, 27, 28, 27, 28], dtype=int64), 'Losses': array([5, 4, 7, 4, 5, 5], dtype=int64), 'Goals': array([89, 78, 86, 68, 80, 83], dtype=int64), 'Goals Conceded': array([33, 37, 28, 24, 22, 27], dtype=int64), 'Clean Sheets': array([20, 15, 19, 24, 21, 16], dtype=int64), 'index': array([0, 1, 2, 3, 4, 5], dtype=int64)}