在Ubuntu上配置MongoDB内存使用,主要是通过修改配置文件/etc/mongod.conf
来实现,具体步骤如下:
nano
)打开配置文件:sudo nano /etc/mongod.conf
。storage
部分,若没有则添加。storage
部分下,设置wiredTiger
存储引擎的cacheSizeGB
参数,单位为GB,根据系统内存和实际需求调整,例如cacheSizeGB: 4
。sudo systemctl restart mongod
。此外,还可通过db.serverStatus().wiredTiger.cache
命令验证配置是否生效,查看缓存状态信息。