在为 50GB 集合添加时间戳字段上的单个索引时,MongoDB 在 96GB 根服务器上的内存不足。
MongoDB 是否有任何选项可以在“安全模式”下运行查询或任务,例如不削减内存太多?它似乎很敏感,可能会崩溃,例如通过在非索引时间戳字段上使用 $lte/$gt 运行一些查找查询。
请您参考如下方法:
i can't control it, but shouldn't there a mongodb config setting for "safety" which makes sure to release RAM once it's breaking the limit? maybe even before it is blocking other processes or stoped by oom killer?
MongoDB 不使用自己的内存管理。相反,它使用操作系统的 LRU。操作系统正在大量分页文档,因为它使用了分配给
mongod 的内存量。 ,也就是您的工作集大于您为 MongoDB 预留的 RAM 量,因为 MongoDB 正在为大部分而不是所有数据交换页面错误(分页的一个很好的引用:
http://en.wikipedia.org/wiki/Paging)。
我强烈不建议在这种情况下限制 MongoDB,因为它会运行得更糟,但是,尤其是在 Linux 上,您实际上可以使用
ulimit在
mongo您用来运行
mongod 的用户:
http://docs.mongodb.org/manual/administration/ulimit/
Does MongoDB have any option to run a query or task in "safe-mode", e.g. without cutting the memory too much?
并不真地。
It seems to be very touchy and can be crashed, e.g. by running some find queries with $lte/$gt on a non-indexed timestamp field.
当然,这不会导致 MongoDB 出现 OOM 异常,它可能表明某处存在内存泄漏: http://docs.mongodb.org/manual/administration/ulimit/
If you limit the resident memory size on a system running MongoDB you risk allowing the operating system to terminate the mongod process under normal situations. Do not set this value. If the operating system (i.e. Linux) kills your mongod, with the OOM killer, check the output of serverStatus and ensure MongoDB is not leaking memory.


