我在Windows Server 2012上使用Mongodb已有两年以上。自上次更新以来,开始出现一些奇怪的问题,最终导致整个RAM内存的使用。
为Mongodb配置的服务如下:
logpath=d:\data\log\mongod.log
dbpath=d:\data\db
storageEngine=wiredTiger
rest=true
#override port
port=27017
#configsvr = true
shardsvr = true
为了限制高速缓存的使用,我添加了以下行:
wiredTigerCacheSizeGB=10
这就是奇怪的事情开始发生的地方。当我检查任务管理器时,它说现在Mongodb实际上限制为我在服务中定义的10GB,但实际上它使用的空间远远超过10GB。
在第一个图像中,您可以看到按RAM消耗排序的内存消耗
这种疯狂的消耗会导致我正在运行的脚本(即使是最基本的脚本)也失败,即使当我仅运行诸如“ count”或“ distinct”之类的简单查询时,我也认为这是内存消耗的直接结果。
当我检查日志文件时,我看到有许多打开的连接,即使会话结束,也表明打开了相同数量的连接:
因此,最后我有两个主要问题:1.有没有一种方法可以解决此问题而不降级Mongodb版本?2.配置文件看起来正确吗?有什么需要的吗?
WiredTiger中的内存使用情况是两级缓存:
--wiredTigerCacheSizeGB
See also WiredTiger memory usage
For OS filesystem cache, MongoDB doesn't manage the memory it uses directly - it lets the OS manage it. Windows will try to use every last scrap of physical memory if it can - but lots of it should and will be thrown out if other processes request memory.
An alternative is to run mongod
in a container (e.g. lxc, cgroups, Docker, etc.) that does not have access to all of the RAM available in a system.
Having said the above:
You are also running another database in the server i.e. mysqld
. MongoDB, like some databases will perform better on a dedicated server to reduce memory contention.
任务管理器显示mongod
正在使用10GB,尽管计算机正在使用约28GB。这可能会也可能不会,mongod
因为您还有其他过程。
有用的资源:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句