$ cat test.config
dbpath = /var/mongodb
logpath = /var/test.log
logappend = true
fork = true
port = 1234
$ sudo ./mongod --config test.config
forked process: 2262
all output going to: /var/test.log
5. serverStatus
在 mongo 中执行 admin.serverStatus() 命令可以获取 MongoDB 的运行统计信息。
$ ./mongo
MongoDB shell version: 1.5.4
connecting to: test
> use admin
switched to db admin
> db.serverStatus()
{
"version" : "1.5.4",
"uptime" : 23,
"uptimeEstimate" : 0,
"localTime" : "Sun Jul 25 2010 01:07:18 GMT+0800 (CST)",
"globalLock" : {
"totalTime" : 23074558,
"lockTime" : 470,
"ratio" : 0.000020368754192387997
},
"mem" : {
"bits" : 64,
"resident" : 2,
"virtual" : 75,
"supported" : true,
"mapped" : 0
},
"connections" : {
"current" : 1,
"available" : 19999
},
"extra_info" : {
"note" : "fields vary by platform",
"heap_usage_bytes" : 162672,
"page_faults" : 0
},
"indexCounters" : {
"btree" : {
"accesses" : 0,
"hits" : 0,
"misses" : 0,
"resets" : 0,
"missRatio" : 0
}
},
"backgroundFlushing" : {
"flushes" : 0,
"total_ms" : 0,
"average_ms" : 0,
"last_ms" : 0,
"last_finished" : "Thu Jan 01 1970 08:00:00 GMT+0800 (CST)"
},
"opcounters" : {
"insert" : 0,
"query" : 1,
"update" : 0,
"delete" : 0,
"getmore" : 0,
"command" : 2
},
"asserts" : {
"regular" : 0,
"warning" : 0,
"msg" : 0,
"user" : 0,
"rollovers" : 0
},
"ok" : true
}
相关字段说明:
uptime: 服务器运行时间(秒)。
localTime: 服务器本地时间。
mem: 服务器内存信息。
connections: 当前连接数。
opcounters: 操作统计。
6. http console