db.serverStatus()
查看服务器运行状态
语法
db.serverStatus()说明
返回 mongod 实例的全局状态指标,涵盖连接数、锁、网络、操作统计、内存使用、WiredTiger 缓存等维度。是性能监控和故障排查的必用命令。输出非常大,通常按需过滤查看。
示例
查看完整状态
返回所有服务器指标
db.serverStatus()查看连接信息
过滤查看连接相关指标
db.serverStatus().connections查看操作计数
查看各类型操作累计执行次数
db.serverStatus().opcounters查看内存使用
检查 WiredTiger 缓存命中率
db.serverStatus().wiredTiger.cache