/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})
。