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. MQ与logstash实现ES与数据库同步区别

    Logstash 实现ES 与数据库同步: 使用定时器(使用sql 定时的去查询数据进行同步).实现方式比较简单. MQ 实现 ES 与数据库同步: 实时性,消息放到MQ中,消费者会自动的消费,复杂性 ...

  2. [转]Entity Framework 异常: 'OFFSET' 附近有语法错误。\r\n在 FETCH 语句中选项 NEXT 的用法无效

    https://blog.csdn.net/weixin_34321977/article/details/85850064 在使用 EF 的时候,突然发现更新后在服务器中运行出错,异常信息主要包含以 ...

  3. vue+iview tables多个分页实现

    如果一个页面有多个分页那么可以把每个page和pageSize放到一个对象中,如下: dataList: { name: 'dataList', // 方便取到dataList对象 id: null, ...

  4. nginx代理(正向代理和反向代理)

    正向代理 是一个位于客户端和原始服务器(origin server)之间的服务器,为了从原始服务器取得内容,客户端向代理发送一个请求并指定目标(原始服务器),然后代理向原始服务器转交请求并将获得的内容 ...

  5. 移动端调试工具Vconsole

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. 记一次渗透某XX站

    0X00 前言 团队A师傅发来个站,问我有没有得搞 正好在搞其他的站,卡住了,开干换个思路. 0x01 信息收集 开burp抓了下包,目标设置了url重写,开了报错,我们随意输入一个控制器就直接报错. ...

  7. hive四种排序

    order by order by 会对输入做全局排序,因此只有一个reducer(多个reducer无法保证全局有序)只有一个reducer,会导致当输入规模较大时,需要较长的计算时间. set h ...

  8. python网络爬虫之爬取图片

    今天使用requests和BeautifulSoup爬取了一些图片,还是很有成就感的,注释可能有误,希望大家多提意见: 方法一:requests import requests from bs4 im ...

  9. Python面向对象之进阶

    一.property 内置函数 装饰器的使用:所有的装饰器函数.方法.类的上一行直接@装饰器的名字 装饰器的分类: ① 装饰函数 ② 装饰方法 ③ 装饰类 property 是一个装饰器函数 @pro ...

  10. Linux命令——mesg

    参考:图解Linux命令之--mesg命令 Linux mesg命令 前言 在看一个脚本~/.profile 的时候发现了mesg命令以及一个奇怪用法 ~/.profile # ~/.profile: ...