首页 > IT职业 > IT职场 > 如何限制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
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2799/viewspace-2833787/ ,如需转载,请注明出处,否则将追究法律责任。