簡體   English   中英

Wordpress錯誤建立數據庫連接 - 內存問題

[英]Wordpress error establishing a database connection - Memory Issue

我已經在這個wordpress網站上運行了很長時間,沒有任何問題,但是最近卻收到錯誤消息“建立數據庫連接時出錯”。 如果我重新啟動mySQL,問題會暫時解決,但很快就會回來。

瀏覽完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

這是您的服務器內存的問題。 從您的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

alexander.polomodov是在正確的軌道上,但我猜你需要更改的配置是MPM-Prefork配置中的MaxRequestWorkers(或舊Apache系統上的MaxClients)。

您可以使用Apache2Buddy對apache配置運行診斷程序。 在給定的RAM數量和應用程序大小的情況下,它將計算可以運行的Apache Worker數量: $ curl -L http://apache2buddy.pl/ | perl $ curl -L http://apache2buddy.pl/ | perl

只需將值更新為Apache2建議的值即可(配置位於系統上的/etc/apache2/mods-available/mpm_prefork.conf )。 之后,只需重新啟動Apache,您就應該做好了。

如果您的網站處理的流量不多,則可能會受到漫游器的攻擊。 檢查您的Apache訪問日志$ cat /var/log/apache2/access.log

如果您想要更深入的解釋,壓力測試的方法或者如何阻止某些機器人流量的想法,我寫了一篇關於這種情況的文章: http//brunzino.github.io/blog/2016/05/21/解決方案如何調試的間歇錯誤,建立數據庫連接/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM