问题描述
我遇到了这个 mongo 游标超时异常.实际上,我正在从 twitter 和 facebook 等社交网站制作一个提要聚合器.我正在运行一个 cron 来每两分钟获取一次推文,并将这些推文保存到我的本地数据库中.我有另一个脚本正在解析提要并提取所需的信息并将它们持久化到另一个数据库.问题是解析器持续运行并解析提要.但是,我遇到了此游标超时异常.我试图从本地数据库一次只检索 50 条推文进行解析.它仍然抛出游标异常我也正确地索引了数据库.仅供参考,我的服务器有 8GB 的硬盘和 700 MB 的内存.我觉得这个配置刚开始应该已经够用了.目前,我的数据库中只存储了 60000 条推文,其中 20000 条需要解析.但它仍然不断抛出游标超时异常.
I am having this mongo cursor timeout exception. Actually, I am making a feed aggregator from social sites like twitter and facebook. I am running a cron to fetch the tweets every two minutes and persisting those tweets to my local db. I have another script that is parsing the feeds and extracting required information and persisting them to another database. The problem is the parser is running continuously and parsing the feeds. However, I am having this cursor time out exception. I am trying to retrieve just 50 tweets at a time from the local db for parsing. Still it is throwing cursor exceptionI have also indexed the database properly. FYI my server has harddisk of 8GB and ram of 700 MB. I think this configuration should have been enough for the start. Currently I have just 60000 tweets stored in my database out of which 20000 need to be parsed. But still it is throwing cursor timeout exception continuously.
任何建议.
推荐答案
如果你使用的是PHP驱动,你可以通过
If you using a PHP driver, you can turn off the timeout for all queries by
MongoCursor::$timeout = -1;
(-1 表示没有超时)
MongoCursor::$timeout = -1;
(-1 is no timeout)
而且我认为其他驱动程序可能具有相同的查询选项.(阅读手册)
And I think other drivers may have the same options for query. (read the manual)
这篇关于Mongo CursorTimeout 异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!