内存管理
/etc/mongod.conf中storage.wiredTiger.engineConfig.cacheSizeGB,建议设置为系统内存的50%-70%。db.serverStatus().mem查看内存占用详情,或使用top、htop等工具实时监控。CPU与连接数优化
net.maxIncomingConnections,避免过多空闲连接占用资源。磁盘与I/O优化
df -h查看磁盘空间,避免数据文件占满磁盘。系统级资源限制
/lib/systemd/system/mongod.service),添加MemoryLimit和CPUQuota参数。vm.swappiness=0减少Swap依赖,或通过ulimit临时限制进程内存。监控与维护工具
mongostat(实时性能监控)、mongotop(数据库读写热点分析)。参考来源: