MongoDB在Ubuntu上的内存使用情况可通过以下方式查看和管理:
top
或 htop
命令查看MongoDB进程的内存占用情况。db.serverStatus().mem
:查看内存使用详情(如缓存、虚拟内存等)。db.stats()
:查看数据库存储占用情况。mongostat
工具:实时监控内存消耗、操作统计等。/etc/mongod.conf
,设置 storage.wiredTiger.engineConfig.cacheSizeGB
参数控制缓存大小(单位为GB)。sudo systemctl restart mongod
。vm.swappiness=0
限制)。