这篇文章主要介绍限制mongodb启动时占用过多内存的方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

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

Startingin3.4,theWiredTigerinternalcache,bydefault,willusethelargerofeither:50%ofRAMminus1GB,or256MB.

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

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

storage:dbPath:/var/lib/mongodbjournal:enabled:true#engine:mmapv1:smallFiles:truewiredTiger:engineConfig:configString:cache_size=160M

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

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

以上是限制mongodb启动时占用过多内存的方法的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!