MongoDB列入致命错误黑名单 [英] MongoDB Blacklisted Fatal Error

查看:218
本文介绍了MongoDB列入致命错误黑名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经见过几次这个错误,为了解决这个问题,我只是重新启动了服务器.

I've seen this error a couple of times, and to fix it, I just reboot my server.

致命错误:未捕获的异常'MongoConnectionException'与 消息无法连接到:localhost:27017:以前的连接 尝试失败,服务器已列入黑名单 /var/www/html/include/config.php:9堆栈跟踪:#0 /var/www/html/include/config.php(9): MongoClient-> __construct('mongodb://local ...')#1 /var/www/html/classes.php(3):include('/var/www/html/i ...')#2 /var/www/html/myusers.php(8):include('/var/www/html/c ...')#3 {main} 在第9行的/var/www/html/include/config.php中抛出

Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: localhost:27017: Previous connection attempts failed, server blacklisted' in /var/www/html/include/config.php:9 Stack trace: #0 /var/www/html/include/config.php(9): MongoClient->__construct('mongodb://local...') #1 /var/www/html/classes.php(3): include('/var/www/html/i...') #2 /var/www/html/myusers.php(8): include('/var/www/html/c...') #3 {main} thrown in /var/www/html/include/config.php on line 9

但是,我可能有一段时间没有看到它...如何防止该问题发生?

However, I can be a while without seeing it... How can I prevent the issue from happening?

更新:再次发生,等待了几分钟后,我不得不重新启动以使站点再次正常工作

update: it happened again and after several minutes of waiting, I had to reboot to make the site work again

推荐答案

自从1.4版的MongoDB PHP驱动程序以来,如果无法联系到服务器,我们会将其列入黑名单长达一分钟.这样一来,我们就不会用连接攻击服务器,这可能会超时.这样做主要是为了确保在副本集环境中我们仍然可以通过使用其他主机继续进行操作,但是当然,如​​果您只有一台计算机,这会有些棘手.

Since the 1.4 versions of the MongoDB driver for PHP we will "blacklist" servers for up to a minute if they can not be contacted to. This is so that we do not slam the server with connections, that might timeout. This is primarily done to make sure that in a replica set environment we can still proceed by just using another of the hosts, but of course if you only have one machine, this is a bit trickier.

如果您使用MongoLog,则可以很容易地发现幕后发生的事情:

If you use MongoLog then you can very easily spot what happens under the hood:

MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::ALL);
MongoLog::setCallback('print_mongo_log');
function print_mongo_log($a, $b, $c) { echo $c, "\n"; }

这将显示驱动程序正在尝试执行的所有操作.有趣的是,先首先转储出现问题的时间,也有一次它被塞入"黑名单.

This will display everything the driver is trying to do. It would be interesting to see the first dump of when something goes wrong, and also for one time it is "stuck" on the blacklist.

上述警告将在60秒后或在重新启动Web服务器软件(或使用PHP-FPM)后消失.如果您认为此解释不正确,请在 http://jira.mongodb处提交错误/功能请求. org/browse/PHP

The above warning will go away after 60 seconds, or upon reboot of your web server software (or PHP-FPM is you use that). If you think this explanation is not correct, please file a bug/feature request at http://jira.mongodb.org/browse/PHP

这篇关于MongoDB列入致命错误黑名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆