/etc/mongod.conf
中storage.wiredTiger.engineConfig.cacheSizeGB
参数设置,建议为系统可用内存的60%左右。vm.swappiness=0
减少交换,避免内存不足时使用磁盘。db.serverStatus().mem
查看内存使用详情(常驻、虚拟、映射内存);top -p $(pidof mongod)
或free -m
监控进程内存占用。mongostat
、mongotop
实时监控内存及性能指标。maxPoolSize
和空闲时间maxIdleTimeMS
。db.adminCommand({setParameter: 1, tcmallocAggressiveMemoryDecommit: 1})
。