以下是一个Ubuntu MongoDB性能调优实战案例:
free -m查看内存使用情况,根据实际情况增加内存。iostat或vmstat监控磁盘I/O。/etc/mongod.conf文件,设置storage.wiredTiger.engineConfig.cacheSizeGB为物理内存的50%-75%。net.maxIncomingConnections和net.maxOutgoingConnections。operationProfiling参数设置。db.users.createIndex({username: 1})。db.collection.getIndex()查看索引,删除无用索引。mongostat和mongotop监控数据库性能,也可借助Prometheus和Grafana进行更详细监控。mongodump和mongorestore备份数据。