在实际应用中,我们有时候会遇到“有什么方法可以限制MongoDB启动时占用内存太多”这样的问题,我们该怎样来处理呢?下文给大家介绍了解决方法,希望这篇“有什么方法可以限制MongoDB启动时占用内存太多”文章能帮助大家解决问题。
默认情况下,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
到此这篇关于“有什么方法可以限制MongoDB启动时占用内存太多”的文章就介绍到这了,小编将为大家输出更多高质量的实用文章!