ITPub博客

首页 > IT职业 > IT职场 > 如何限制mongodb启动时占用过多内存

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

IT职场 作者:fengwei 时间:2021-09-11 10:17:36 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

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2799/viewspace-2833787/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-16

  • 博文量
    90
  • 访问量
    675