mongostat工具
- mongostat:查看mongodb运行状态的程序
- 使用说明:mongostat -h 127.0.0.1:12345
- 字段说明
- 索引情况:idx miss
> 查看mongodb运行状态
jhw2@ubuntu:~/mongodb$ ./bin/mongostat -h 127.0.0.1:12345
insert query update delete getmore command dirty used flushes vsize res qrw arw net_in net_out conn time
*0 *0 *0 *0 0 2|0 0.0% 0.0% 0 272M 62.0M 0|0 0|0 211b 44.5k 2 Jan 9 10:41:43.147
*0 *0 *0 *0 0 2|0 0.0% 0.0% 0 272M 62.0M 0|0 0|0 158b 44.8k 2 Jan 9 10:41:44.141
*0 *0 *0 *0 0 1|0 0.0% 0.0% 0 272M 62.0M 0|0 0|0 157b 44.4k 2 Jan 9 10:41:45.145
*0 *0 *0 *0 0 2|0 0.0% 0.0% 0 272M 62.0M 0|0 0|0 158b 44.7k 2 Jan 9 10:41:46.142
> 运行以下代码,插入数据
> for(i=0;i<1000000;i++)db.imooc_2.insert({x:i})
> 切换另一个xshell连接界面,执行以下代码,查看mongodb运行状态
jhw2@ubuntu:~/mongodb$ ./bin/mongostat -h 127.0.0.1:12345
insert query update delete getmore command dirty used flushes vsize res qrw arw net_in net_out conn time
2451 *0 *0 *0 0 2|0 0.7% 0.7% 0 272M 62.0M 0|0 0|0 297k 155k 2 Jan 9 10:57:43.806
2367 *0 *0 *0 0 1|0 0.9% 0.9% 0 272M 62.0M 0|0 0|0 287k 151k 2 Jan 9 10:57:44.809
2363 *0 *0 *0 0 1|0 1.0% 1.0% 0 272M 62.0M 0|0 0|0 286k 151k 2 Jan 9 10:57:45.815
9. profile集合介绍
> db.getProfilingStatus()
{ "was" : 0, "slowms" : 100 }
>
> db.getProfilingLevel()
0
> db.getProfilingStatus()
{ "was" : 0, "slowms" : 100 }
>
> db.system.profile.find()
>
> db.system.profile.find().sort({$natural:-1}).limit(1)
>
10. 日志管理
> 在配置文件中使用verbose 设置日志的详细程度,级别为一个v到五个v,v越多详细度越高
varbose = vvvvv
11. explain
> db.imooc_2.find({x:1})
{ "_id" : ObjectId("5872fc23193a8ea63df5ee8a"), "x" : 1 }
> db.imooc_2.find({x:1}).explain()
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "imooc.imooc_2",
"indexFilterSet" : false,
"parsedQuery" : {
"x" : {
"$eq" : 1
}
},
"winningPlan" : {
"stage" : "COLLSCAN",
"filter" : {
"x" : {
"$eq" : 1
}
},
"direction" : "forward"
},
"rejectedPlans" : [ ]
},
"serverInfo" : {
"host" : "ubuntu",
"port" : 12345,
"version" : "3.4.1",
"gitVersion" : "5e103c4f5583e2566a45d740225dc250baacfbd7"
},
"ok" : 1
}
>
网友评论