品易云推流 关闭
文章详情页
文章 > MongoDB > 如何限制mongodb启动时占用过多内存

如何限制mongodb启动时占用过多内存

头像

yang

2020-05-05 11:34:542839浏览 · 0收藏 · 0评论

默认情况下,mongodb占用的内存大小为:

Starting in 3.4, the WiredTiger internal cache, by default, will use the larger of either:

50% of RAM minus 1 GB, or
256 MB.

下面我们来看一下限制mongodb启动时占用内存的方法:

新增配置文件 /etc/mongod.conf

storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
  mmapv1:
    smallFiles: true
  wiredTiger:
    engineConfig:
      configString : cache_size=160M

然后以配置文件的方式启动:

mongod -f /etc/mongod.conf --fork --logpath=/etc/mongodb.log
关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图