间歇性地发生数据库错误连接

时间:2014-08-11 16:12:54

标签: php mysql wordpress apache

当我使用Woorank时,我遇到了Wordpress项目的问题。

整个网站工作正常,但在向Woorank提交网址时,会显示“连接到数据库时出错”。然后,如果我尝试从浏览器正常访问,我也会得到同样的错误。这种情况发生,直到我重新启动mysql(service mysql restart),或者当网站再次正常工作时,用管理员用户重新加载主页面。

认为它应该是WP问题,我禁用了所有插件,更改主题,.htaccess指令,检查wp-config.php,...但仍然出现错误。

项目位于VPS中,还有一些项目不受此问题的影响。 我最近安装了Nginx作为代理,但之前也存在问题。

我认为这个问题是由于一次有很多连接,因为我不能在不使用Woorank的情况下重现它。

提交Woorank表单后的mysql日志:

140811 17:50:54 [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.
140811 17:50:54 [Note] Plugin 'FEDERATED' is disabled.
140811 17:50:54 InnoDB: The InnoDB memory heap is disabled
140811 17:50:54 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140811 17:50:54 InnoDB: Compressed tables use zlib 1.2.3.4
140811 17:50:54 InnoDB: Initializing buffer pool, size = 128.0M
140811 17:50:54 InnoDB: Completed initialization of buffer pool
140811 17:50:54 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 938907976
140811 17:50:54  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 938908419
140811 17:50:54  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
140811 17:50:54  InnoDB: Waiting for the background threads to start
140811 17:50:55 InnoDB: 5.5.38 started; log sequence number 938908419
140811 17:50:55 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
140811 17:50:55 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
140811 17:50:55 [Note] Server socket created on IP: '127.0.0.1'.
140811 17:50:55 [Note] Event Scheduler: Loaded 0 events
140811 17:50:55 [Note] /usr/sbin/mysqld: ready for connections.

Apache2的日志:

[Mon Aug 11 17:50:25.136960 2014] [:error] [pid 11656] [client 127.0.0.1:46584] Error Lost connection to MySQL server during query de la base de datos de WordPress para la consulta select val from bio_wfConfig where name='liveTrafficEnabled' realizada por require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), call_user_func_array, wordfence::initAction, wfConfig::liveTrafficEnabled, wfConfig::get, wfConfig::loadFromDiskCache, wfDB->querySingle
[Mon Aug 11 17:50:25.141243 2014] [:error] [pid 11173] [client 127.0.0.1:46589] Error Lost connection to MySQL server during query de la base de datos de WordPress para la consulta SELECT t.*, tt.* FROM bio_terms AS t INNER JOIN bio_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'category' AND t.slug = 'biomedicina' LIMIT 1 realizada por require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, get_term_by
[Mon Aug 11 17:50:25.191699 2014] [:error] [pid 11644] [client 127.0.0.1:46578] Error Lost connection to MySQL server during query de la base de datos de WordPress para la consulta \n\t\tSELECT ID, post_name, post_parent, post_type\n\t\tFROM bio_posts\n\t\tWHERE post_name IN ('news')\n\t\tAND post_type IN ('page','attachment')\n\t realizada por require('wp-blog-header.php'), wp, WP->main, WP->parse_request, get_page_by_path
[Mon Aug 11 17:50:25.195749 2014] [:error] [pid 11652] [client 127.0.0.1:46582] Error Lost connection to MySQL server during query de la base de datos de WordPress para la consulta SELECT option_value FROM bio_options WHERE option_name = 'jetpack_portfolio' LIMIT 1 realizada por require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), call_user_func_array, Jetpack_Portfolio::init, Jetpack_Portfolio->__construct, get_option
[Mon Aug 11 17:50:25.201487 2014] [:error] [pid 11668] [client 127.0.0.1:46587] Error Lost connection to MySQL server during query de la base de datos de WordPress para la consulta select val from bio_wfConfig where name='liveTrafficEnabled' realizada por require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), call_user_func_array, wordfence::initAction, wfConfig::liveTrafficEnabled, wfConfig::get, wfConfig::loadFromDiskCache, wfDB->querySingle
[Mon Aug 11 17:50:25.212494 2014] [:error] [pid 11148] [client 127.0.0.1:46594] Error Lost connection to MySQL server during query de la base de datos de WordPress para la consulta select val from bio_wfConfig where name='liveTrafficEnabled' realizada por require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), call_user_func_array, wordfence::initAction, wfConfig::liveTrafficEnabled, wfConfig::get, wfConfig::loadFromDiskCache, wfDB->querySingle
[Mon Aug 11 17:50:25.214185 2014] [:error] [pid 11110] [client 127.0.0.1:46586] Error Lost connection to MySQL server during query de la base de datos de WordPress para la consulta SELECT option_value FROM bio_options WHERE option_name = 'wpseo_flush_rewrite' LIMIT 1 realizada por require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), call_user_func_array, WPSEO_Rewrite->flush, get_option
[Mon Aug 11 17:50:25.982309 2014] [:error] [pid 11638] [client 127.0.0.1:46618] Error Lost connection to MySQL server during query de la base de datos de WordPress para la consulta SELECT option_value FROM bio_options WHERE option_name = 'embed_autourls' LIMIT 1 realizada por require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('plugins_loaded'), call_user_func_array, Jetpack::load_modules, require('/plugins/jetpack/modules/shortcodes.php'), jetpack_load_shortcodes, include('/plugins/jetpack/modules/shortcodes/youtube.php'), get_option
[Mon Aug 11 17:50:25.928911 2014] [:error] [pid 11226] [client 127.0.0.1:46620] Error Lost connection to MySQL server during query de la base de datos de WordPress para la consulta SELECT option_value FROM wp_options WHERE option_name = 'akismet_comment_nonce' LIMIT 1 realizada por require('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), include_once('/plugins/akismet/akismet.php'), get_option, W3_Db->query, W3_DbCache->query, W3_DbCallUnderlying->query, W3_Db->query, W3_DbProcessor->query, W3_Db->default_query
[Mon Aug 11 17:50:35.154185 2014] [:error] [pid 11173] [client 127.0.0.1:46589] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
[Mon Aug 11 17:50:35.410068 2014] [:error] [pid 11644] [client 127.0.0.1:46578] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您有两个主要选择......

1)您可以花费无数个小时来审核WordPress根据您的主题和您使用的所有插件创建的查询,然后对问题进行优化,直到问题不再发生(根据您的托管环境可能或可能不可行) )。

- 或 -

2)安装WP Super Cache(https://wordpress.org/plugins/wp-super-cache/)之类的东西,这样数据库就不会受到严重打击。它基本上是一个完整的页面缓存,可以消除您对其所处压力类型的数据库访问。如果您愿意,可以在您不扫描时停用。确保在从Woorank运行扫描之前预加载缓存。