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的状态分析的更多相关文章

  1. 【MongoDB】应用场景

    24 Use Cases24.1 适合场景 Archiving and event logging 归档和日志记录 Document and Content Management Systems ...

  2. mongodb监控常用方法

    列举mongodb监控的常用命令 1.监控统计 mongostat 可用于查看当前QPS/内存使用/连接数,以及多个shard的压力分布 命令参考 ./mongostat --port 27071 - ...

  3. Mongodb 3 查询优化(语句优化、建索引)

    一.explain(),语句分析工具 MongoDB 3.0之后,explain的返回与使用方法与之前版本有了很大的变化,介于3.0之后的优秀特色和我们目前所使用给的是3.0.7版本,本文仅针对Mon ...

  4. mongodb .explain('executionStats') 查询性能分析(转)

    mongodb性能分析方法:explain() 为了演示的效果,我们先来创建一个有200万个文档的记录.(我自己的电脑耗了15分钟左右插入完成.如果你想插更多的文档也没问题,只要有耐心等就可以了.) ...

  5. MongoDB使用优化

    一.监控 mongodb可以通过profile来监控数据,进行优化. 查看当前是否开启profile功能用命令:db.getProfilingLevel()返回level等级,值为0|1|2,分别代表 ...

  6. 玩转mongodb(五):mongodb 3.0+ 查询性能分析

    mongodb性能分析方法:explain() 为了演示的效果,我们先来创建一个有200万个文档的记录.(我自己的电脑耗了15分钟左右插入完成.如果你想插更多的文档也没问题,只要有耐心等就可以了.) ...

  7. MongoDB分析工具之一:explain()语句分析工具

    explain(),语句分析工具 MongoDB 3.0之后,explain的返回与使用方法与之前版本有了很大的变化,介于3.0之后的优秀特色和我们目前所使用给的是3.0.7版本,本文仅针对Mongo ...

  8. MongoDB executionStats 详细分步查询计划与分步时间(转载)

    mongodb性能分析方法:explain() 为了演示的效果,我们先来创建一个有200万个文档的记录.(我自己的电脑耗了15分钟左右插入完成.如果你想插更多的文档也没问题,只要有耐心等就可以了.) ...

  9. 【翻译】MongoDB指南/聚合——聚合管道

    [原文地址]https://docs.mongodb.com/manual/ 聚合 聚合操作处理数据记录并返回计算后的结果.聚合操作将多个文档分组,并能对已分组的数据执行一系列操作而返回单一结果.Mo ...

随机推荐

  1. js new到底做了什么?如何重写new?(转)

    转自:https://blog.csdn.net/lyt_angularjs/article/details/86623988

  2. JQuery实现密码可见不可见

    在Html页面上实现密码可见不可见,使用的阿里巴巴矢量图标库. html部分: <!doctype html> <html> <head> <meta cha ...

  3. 将网站升级为https并自动续期Https证书。

    Let's Encrypt Let's Encrypt 是一个由Internet Security Research Group (互联网安全研究组)提供的免费,自动化和开放的证书颁发机构. 它秉承着 ...

  4. English-培训5-How much is it

  5. iOS退出APP

    强制退出有四种: exit(); abort(); assert(); 主动制造一个崩溃: exit() 1.附加了关闭打开文件与返回状态码给执行环境,并调用你用atexit注册的返回函数: 2.警告 ...

  6. iOS 数据源切换混乱问题

    问题场景 这个问题遇到是偶然的,正常来说是不会出现的.但是有时候在一些极端操作情况下,还是出现了. 现在我说明下这个场景.页面上是一个tableview,那对应的有一个dataSource,页面顶部有 ...

  7. Robo 3T SQL

    查询指定日期,指定显示字段,排序,注释功能 db.getCollection('spuBasisInfo') .find({"createTime":{$gte:ISODate(& ...

  8. Linux 之 文件

    文件名称 在linux中,windows概念中的文件夹和文件是没有区别的,都是统称为文件. 1.Linux中文件的名称大小写是敏感的 2.名称最多可以为255个字符 3.除了正斜线以外,都是有效字符 ...

  9. CentOS7.X版本系统的下载和安装

    一.下载CentOS镜像 1.打开浏览器输入centos.org 2.选择版本下载 3.进入下载页面选择下载版本的种子链接,在迅雷下载即可. 二安装CentOS系统 1.服务器开机,根据界面提示进入磁 ...

  10. DoraBox漏洞测试环境搭建和测试过程

    未完待续...