mongodb的状态分析
1.借助工具 mongostat 分析mongodb运行状况
C:\Users\Administrator>mongostat --help //查看帮助
View live MongoDB performance statistics. usage: mongostat [options] [sleep time]
sleep time: time to wait (in seconds) between calls
Options:
--help produce help message
-v [ --verbose ] be more verbose (include multiple times
for more verbosity e.g. -vvvvv)
--quiet silence all non error diagnostic
messages
--version print the program's version and exit
-h [ --host ] arg mongo host to connect to ( <set
name>/s1,s2 for sets)
--port arg server port. Can also use --host
hostname:port
--ipv6 enable IPv6 support (disabled by
default)
-u [ --username ] arg username
-p [ --password ] arg password
--authenticationDatabase arg user source (defaults to dbname)
--authenticationMechanism arg (=MONGODB-CR)
authentication mechanism
--gssapiServiceName arg (=mongodb) Service name to use when authenticating
using GSSAPI/Kerberos
--gssapiHostName arg Remote host name to use for purpose of
GSSAPI/Kerberos authentication
--noheaders don't output column names
-n [ --rowcount ] arg (=) number of stats lines to print ( for
indefinite)
--http use http instead of raw db connection
--discover discover nodes and display stats for
all
--all all optional fields Fields
inserts - # of inserts per second (* means replicated op)
query - # of queries per second
update - # of updates per second
delete - # of deletes per second
getmore - # of get mores (cursor batch) per second
command - # of commands per second, on a slave its local|replicated
flushes - # of fsync flushes per second
mapped - amount of data mmaped (total data size) megabytes
vsize - virtual size of process in megabytes
res - resident size of process in megabytes
non-mapped - amount virtual memeory less mapped memory (only with --all)
faults - # of pages faults per sec
locked - name of and percent time for most locked database
idx miss - percent of btree page misses (sampled)
qr|qw - queue lengths for clients waiting (read|write)
ar|aw - active clients (read|write)
netIn - network traffic in - bytes
netOut - network traffic out - bytes
conn - number of open connections
set - replica set name
repl - replication type
PRI - primary (master)
SEC - secondary
REC - recovering
UNK - unknown
SLV - slave
b RTR - mongos process ("router") C:\Users\Administrator>mongostat
connected to: 127.0.0.1
insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr|qw ar|aw netIn netOut conn time
* * * * | 160m 446m 40m test:0.0% | | 62b 3k ::19
2.mongodb慢操作日志 profile
> db.getProfilingLevel() //查看慢日志记录级别 0=关闭 1=所有超过slowms的操作 2=记录所有查找
> db.setProfilingLevel(){ "was" : , "slowms" : , "ok" : } //设置日志记录级别2
> show tablessystem.profile //这个就是日志集合
> db.system.profile.find().sort({$natural:-}).limit() //自然排序 倒序查看一条日志记录
{
"op": "query",
"ns": "test.system.namespaces",
"query": {
},
"ntoreturn": ,
"ntoskip": ,
"nscanned": ,
"nscannedObjects": ,
"keyUpdates": ,
"numYield": ,
"lockStats": {
"timeLockedMicros": {
"r": NumberLong(),
"w": NumberLong()
},
"timeAcquiringMicros": {
"r": NumberLong(),
"w": NumberLong()
}
},
"nreturned": ,
"responseLength": ,
"millis": ,
"execStats": {
"type": "COLLSCAN",
"works": ,
"yields": ,
"unyields": ,
"invalidates": ,
"advanced": ,
"needTime": ,
"needFetch": ,
"isEOF": ,
"docsTested": ,
"children": [
]
},
"ts": ISODate("2015-09-16T06:14:39.604Z"),
"client": "127.0.0.1",
"allUsers": [
],
"user": ""
}
3.explain 方法显示查询语句的详细信息
> db.system.local.find().explain()
{
"cursor" : "BasicCursor",
"isMultiKey" : false,
"n" : ,
"nscannedObjects" : ,
"nscanned" : ,
"nscannedObjectsAllPlans" : ,
"nscannedAllPlans" : ,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : ,
"nChunkSkips" : ,
"millis" : ,
"server" : "buexplain:27017"
}
mongodb的状态分析的更多相关文章
- 【MongoDB】应用场景
24 Use Cases24.1 适合场景 Archiving and event logging 归档和日志记录 Document and Content Management Systems ...
- mongodb监控常用方法
列举mongodb监控的常用命令 1.监控统计 mongostat 可用于查看当前QPS/内存使用/连接数,以及多个shard的压力分布 命令参考 ./mongostat --port 27071 - ...
- Mongodb 3 查询优化(语句优化、建索引)
一.explain(),语句分析工具 MongoDB 3.0之后,explain的返回与使用方法与之前版本有了很大的变化,介于3.0之后的优秀特色和我们目前所使用给的是3.0.7版本,本文仅针对Mon ...
- mongodb .explain('executionStats') 查询性能分析(转)
mongodb性能分析方法:explain() 为了演示的效果,我们先来创建一个有200万个文档的记录.(我自己的电脑耗了15分钟左右插入完成.如果你想插更多的文档也没问题,只要有耐心等就可以了.) ...
- MongoDB使用优化
一.监控 mongodb可以通过profile来监控数据,进行优化. 查看当前是否开启profile功能用命令:db.getProfilingLevel()返回level等级,值为0|1|2,分别代表 ...
- 玩转mongodb(五):mongodb 3.0+ 查询性能分析
mongodb性能分析方法:explain() 为了演示的效果,我们先来创建一个有200万个文档的记录.(我自己的电脑耗了15分钟左右插入完成.如果你想插更多的文档也没问题,只要有耐心等就可以了.) ...
- MongoDB分析工具之一:explain()语句分析工具
explain(),语句分析工具 MongoDB 3.0之后,explain的返回与使用方法与之前版本有了很大的变化,介于3.0之后的优秀特色和我们目前所使用给的是3.0.7版本,本文仅针对Mongo ...
- MongoDB executionStats 详细分步查询计划与分步时间(转载)
mongodb性能分析方法:explain() 为了演示的效果,我们先来创建一个有200万个文档的记录.(我自己的电脑耗了15分钟左右插入完成.如果你想插更多的文档也没问题,只要有耐心等就可以了.) ...
- 【翻译】MongoDB指南/聚合——聚合管道
[原文地址]https://docs.mongodb.com/manual/ 聚合 聚合操作处理数据记录并返回计算后的结果.聚合操作将多个文档分组,并能对已分组的数据执行一系列操作而返回单一结果.Mo ...
随机推荐
- Eclipse RCP使用SWT.EMBEDDED方式显示batik的svgCanvas后窗口最大化变白问题
// 设置svg组件一直动态(这一行代码导致了最大化变白的问题)svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);// 以下两行解决最大化变白 ...
- javascript 之 call,apply原理
一.call原理 1.使用JQuery的call功能 var add(c,d){ return this.a+this.b+c+d } var obj={a:1,b:2} add.Call(obj,3 ...
- interface Part4(接口中的多态)
使用接口实现多态 需要满足以下两个条件. 定义接口并使用类实现了接口中的成员. 创建接口的实例指向不同的实现类对象. 假设接口名称为 ITest,分别定义两个实现类来实现接口的成员,示例代码如下. i ...
- javascript中bind()、call()、apply()的使用
一直以来对bind().apply().call()这三个方法都模模糊糊的,现在有时间详细的看看这三个方法,并记录下来. bind() 参考文档:https://developer.mozilla.o ...
- ping IP 带时间戳循环显示并写入日志(windos版+linux版)
在工作中,判断网络是否通畅,首选命令就是ping,但有时候我们需要持续ping一个或多个地址时,需要加 -t 即可,但有时候需要在ping的时候加入时间戳并把ping记录写入到日志里面,方法如下: w ...
- c# 克隆来创建对象副本
- java--反射的基本概念
反射的基本概念 如果正常的情况下,如果使用一个类,则必须按照如下的步骤操作: 使用import 导入类所在的包:(类:java.lang.Class) 明确的使用类名称或借口名称定义对象: 通过关键字 ...
- 【转载】抓包工具tcpdump用法说明
转载地址:http://www.cnblogs.com/f-ck-need-u/p/7064286.html tcpdump采用命令行方式对接口的数据包进行筛选抓取,其丰富特性表现在灵活的表达式上. ...
- Linux命令——chkconfig
拓展:如何增加一个系统服务service chkconfig本身用法不复杂,其作用是控制service是否开机启动. 对于CentOS而言,7.X版本已经不再使用SysV,SysV相关的命令基本上没有 ...
- Resource接口
[转]https://blog.csdn.net/hbtj_1216/article/details/85487787 参考:官方文档 1 简介 Java标准库中的java.net.URL类和标准处理 ...