有没有限制mongodb内存使用的选项? [英] Is there any option to limit mongodb memory usage?

查看:23
本文介绍了有没有限制mongodb内存使用的选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Mongo-DBv1.8.1.我的服务器内存是 4GB,但 Mongo-DB 使用了超过 3GB.Mongo-DB 中是否有内存限制选项?.

I am using Mongo-DBv1.8.1. My server memory is 4GB but Mongo-DB is utilizing more than 3GB. Is there memory limitation option in Mongo-DB?.

推荐答案

如果你运行的是MongoDB 3.2或更高版本,你可以限制wiredTiger 缓存 如上所述.

If you are running MongoDB 3.2 or later version, you can limit the wiredTiger cache as mentioned above.

/etc/mongod.conf中添加wiredTiger部分

...
# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
  wiredTiger:
    engineConfig:
        cacheSizeGB: 1
...

这会将缓存大小限制为 1GB,更多信息请参见 文档

This will limit the cache size to 1GB, more info in Doc

这为我解决了这个问题,运行 ubuntu 16.04mongoDB 3.2

This solved the issue for me, running ubuntu 16.04 and mongoDB 3.2

PS:更改配置后,重启mongo daemon.

PS: After changing the config, restart the mongo daemon.

$ sudo service mongod restart

# check the status
$ sudo service mongod status

这篇关于有没有限制mongodb内存使用的选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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