Mongodb错误失败24:打开文件太多:使用pymongo

时间:2016-01-07 23:00:09

标签: mongodb pymongo

我的代码创建了非常繁忙的流量,有很多查找,更新,map reduce和createIndex操作,所以我不确定哪一个可能是罪魁祸首,但我收到以下错误:

_create_global_word_frequency_collection
    full_response=True)
  File "/Users/arj/anaconda/lib/python2.7/site-packages/pymongo/collection.py", line 1857, in map_reduce
    sock_info, cmd, slave_ok, ReadPreference.PRIMARY)
  File "/Users/arj/anaconda/lib/python2.7/site-packages/pymongo/collection.py", line 205, in _command
    read_concern=read_concern)
  File "/Users/arj/anaconda/lib/python2.7/site-packages/pymongo/pool.py", line 211, in command
    read_concern)
  File "/Users/arj/anaconda/lib/python2.7/site-packages/pymongo/network.py", line 100, in command
    helpers._check_command_response(response_doc, msg, allowable_errors)
  File "/Users/arj/anaconda/lib/python2.7/site-packages/pymongo/helpers.py", line 196, in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: command SON([('mapreduce', u'verbatimterms'), ('map', Code('\n                    function(){\n                        this.terms.forEach(function(item){\n                        emit(item, 1)\n                    })\n                }\n                ', {})), ('reduce', Code('\n                    function(key, counts){\n                        return Array.sum(counts)\n                    }\n                ', {})), ('out', SON([('replace', 'reconversations_topic_3'), ('db', 'wcterms')])), ('query', {'topic': 'reconversations_topic_3'})]) on namespace indexes.$cmd failed: 24: Too many open files

出现这种错误的原因是什么?

1 个答案:

答案 0 :(得分:4)

根据文档,您将增加class Page(Base): __tablename__ = 'pages' id = Column(Integer, primary_key=True) title = Column(String(100), nullable=False) content = Column(Text, nullable=False) parent_id = Column(Integer, ForeignKey("pages.id"), nullable=True) parent = relationship("Page", foreign_keys=[parent_id], remote_side=[id], backref=backref("children" )) next_id = Column(Integer, ForeignKey("pages.id"), nullable=True) next = relationship("Page", foreign_keys=[next_id], remote_side=[id], backref=backref("prev", uselist=False)) 。您可以通过在系统提示符下运行以下命令来执行此操作。我已使用建议值,但您可以根据需要增加它。

ulimit

运行此命令后,您需要重新启动MongoDB服务。