2016-03-17 56 views
1

我一直在运行这个WordPress站点很长一段时间没有问题,但最近一直在收到错误“建立数据库连接时出错”。如果我重新启动MySQL,问题暂时得到解决,但很快就会回来。建立数据库连接的Wordpress错误 - 内存问题

查看MySQL日志文件后,我认为问题是由于某种内存泄漏,但我无法追查问题的根源。

   total  used  free  shared buffers  cached 
Mem:   987  968   18   26   18  137 
-/+ buffers/cache:  812  175 
Swap:   255   35  220 

这将是真棒,如果有人可以帮助我使这篇日志的意义:

我已阅读,问题可能来自未配置交换文件是未来,但是我已经配置如下交换文件。

MySQL的日志文件:

2016-03-17 06:48:45 3575 [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. 
2016-03-17 06:48:45 3575 [Note] Plugin 'FEDERATED' is disabled. 
2016-03-17 06:48:45 3575 [ERROR] Function 'innodb' already exists 
2016-03-17 06:48:45 3575 [Warning] Couldn't load plugin named 'innodb' with soname 'ha_innodb.so'. 
2016-03-17 06:48:45 3575 [ERROR] Function 'federated' already exists 
2016-03-17 06:48:45 3575 [Warning] Couldn't load plugin named 'federated' with soname 'ha_federated.so'. 
2016-03-17 06:48:45 3575 [ERROR] Function 'blackhole' already exists 
2016-03-17 06:48:45 3575 [Warning] Couldn't load plugin named 'blackhole' with soname 'ha_blackhole.so'. 
2016-03-17 06:48:45 3575 [ERROR] Function 'archive' already exists 
2016-03-17 06:48:45 3575 [Warning] Couldn't load plugin named 'archive' with soname 'ha_archive.so'. 
2016-03-17 06:48:45 3575 [Note] InnoDB: Using atomics to ref count buffer pool pages 
2016-03-17 06:48:45 3575 [Note] InnoDB: The InnoDB memory heap is disabled 
2016-03-17 06:48:45 3575 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 
2016-03-17 06:48:45 3575 [Note] InnoDB: Memory barrier is not used 
2016-03-17 06:48:45 3575 [Note] InnoDB: Compressed tables use zlib 1.2.8 
2016-03-17 06:48:45 3575 [Note] InnoDB: Using Linux native AIO 
2016-03-17 06:48:45 3575 [Note] InnoDB: Using CPU crc32 instructions 
2016-03-17 06:48:45 3575 [Note] InnoDB: Initializing buffer pool, size = 128.0M 
InnoDB: mmap(137363456 bytes) failed; errno 12 
2016-03-17 06:48:45 3575 [ERROR] InnoDB: Cannot allocate memory for the buffer pool 
2016-03-17 06:48:45 3575 [ERROR] Plugin 'InnoDB' init function returned error. 
2016-03-17 06:48:45 3575 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
2016-03-17 06:48:45 3575 [ERROR] Unknown/unsupported storage engine: InnoDB 
2016-03-17 06:48:45 3575 [ERROR] Aborting 

2016-03-17 06:48:45 3575 [Note] Binlog end 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'partition' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'BLACKHOLE' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'ARCHIVE' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_FIELDS' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_INDEXES' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_SYS_TABLES' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_CONFIG' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_DELETED' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_METRICS' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMPMEM' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMP_RESET' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_CMP' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_LOCK_WAITS' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_LOCKS' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'INNODB_TRX' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'CSV' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'MEMORY' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'MRG_MYISAM' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'MyISAM' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'sha256_password' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'mysql_old_password' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'mysql_native_password' 
2016-03-17 06:48:45 3575 [Note] Shutting down plugin 'binlog' 
2016-03-17 06:48:45 3575 [Note] /usr/sbin/mysqld: Shutdown complete 

2016-03-17 06:48:46 3606 [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. 
2016-03-17 06:48:46 3606 [Note] Plugin 'FEDERATED' is disabled. 
2016-03-17 06:48:46 3606 [ERROR] Function 'innodb' already exists 
2016-03-17 06:48:46 3606 [Warning] Couldn't load plugin named 'innodb' with soname 'ha_innodb.so'. 
2016-03-17 06:48:46 3606 [ERROR] Function 'federated' already exists 
2016-03-17 06:48:46 3606 [Warning] Couldn't load plugin named 'federated' with soname 'ha_federated.so'. 
2016-03-17 06:48:46 3606 [ERROR] Function 'blackhole' already exists 
2016-03-17 06:48:46 3606 [Warning] Couldn't load plugin named 'blackhole' with soname 'ha_blackhole.so'. 
2016-03-17 06:48:46 3606 [ERROR] Function 'archive' already exists 
2016-03-17 06:48:46 3606 [Warning] Couldn't load plugin named 'archive' with soname 'ha_archive.so'. 
2016-03-17 06:48:46 3606 [Note] InnoDB: Using atomics to ref count buffer pool pages 
2016-03-17 06:48:46 3606 [Note] InnoDB: The InnoDB memory heap is disabled 
2016-03-17 06:48:46 3606 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 
2016-03-17 06:48:46 3606 [Note] InnoDB: Memory barrier is not used 
2016-03-17 06:48:46 3606 [Note] InnoDB: Compressed tables use zlib 1.2.8 
2016-03-17 06:48:46 3606 [Note] InnoDB: Using Linux native AIO 
2016-03-17 06:48:46 3606 [Note] InnoDB: Using CPU crc32 instructions 
2016-03-17 06:48:46 3606 [Note] InnoDB: Initializing buffer pool, size = 128.0M 
InnoDB: mmap(137363456 bytes) failed; errno 12 
2016-03-17 06:48:46 3606 [ERROR] InnoDB: Cannot allocate memory for the buffer pool 
2016-03-17 06:48:46 3606 [ERROR] Plugin 'InnoDB' init function returned error. 
2016-03-17 06:48:46 3606 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
2016-03-17 06:48:46 3606 [ERROR] Unknown/unsupported storage engine: InnoDB 
2016-03-17 06:48:46 3606 [ERROR] Aborting 
+0

可以粘贴一些之前会发生什么2016-03-17 06:48:46 3606? – obe

+0

@obe是否添加了您要查找的部分? – Tony

回答

0

这是一个与你的服务器内存不足的问题。从您的MySQL日志文件中,我们可以得知InnoDb插件无法启动,因为无法启动Initializing buffer pool。所以任何带有InnoDb存储的表都会导致错误。

你的解决方法解决

如果我重启MySQL的问题被暂时固定,但很快就会回来。

因为在重新启动Mysql后得到一些空闲内存。

2016-03-17 06:48:46 3606 [Note] InnoDB: Initializing buffer pool, size = 128.0M 
InnoDB: mmap(137363456 bytes) failed; errno 12 
2016-03-17 06:48:46 3606 [ERROR] InnoDB: Cannot allocate memory for the buffer pool 
2016-03-17 06:48:46 3606 [ERROR] Plugin 'InnoDB' init function returned error. 
2016-03-17 06:48:46 3606 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
2016-03-17 06:48:46 3606 [ERROR] Unknown/unsupported storage engine: InnoDB 
2016-03-17 06:48:46 3606 [ERROR] Aborting 
+0

我认为这个错误与此有关。你知道有什么方法可以进一步追踪问题吗? – Tony

+0

用这个字符串'innodb_buffer_pool_size = 20M'可以将mysql配置文件中的缓冲池减少到20M。也许会有足够的内存以此缓冲区大小开始 –

+0

或者您可以为MySQL的max_connections变量设置一个较小的值 –

0

alexander.polomodov是在正确的轨道上,但我猜你需要更改配置是您的MPM-prefork的配置MaxRequestWorkers(或MaxClients的在旧的Apache系统)。

您可以使用Apache2Buddy在您的apache配置上运行诊断。它会计算有多少阿帕奇工人可以运行给你的RAM数量以及有多大你的应用程序是: $ curl -L http://apache2buddy.pl/ | perl

刚刚更新的值是什么Apache2的建议(该CONFIGS是在/etc/apache2/mods-available/mpm_prefork.conf我的系统上)。之后,重新启动Apache,你应该很好。

如果你的网站没有处理大量的流量,你可能会被机器人击中。检查你的Apache访问日志$ cat /var/log/apache2/access.log

我写了一篇关于这种情况的文章,如果你想有一个更深入的解释,进行压力测试的方法,或者对如何阻止某些机器人交通的思路:http://brunzino.github.io/blog/2016/05/21/solution-how-to-debug-intermittent-error-establishing-database-connection/

相关问题