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 ...
随机推荐
- windows安装docker,快捷启动方式无法启动
1.在双击“Docker Quickstart Terminal”时弹出缺少快捷方式,截图如下 2.单机快捷方式查看属性,发现配置的git位置是有问题的 现在只需要把git的正确地址配置好就可以了 现 ...
- dB分贝计算
1. 定义 dB-表征相对值的大小的单位,即两个电.声功率之比或者电流.电压.音量之比,是一种测相对大小的单位. 1.1 电.声功率之比——10lg(x/y) x.y分别表示两个欲比较的功率值. 例如 ...
- Mac 下编译 Hadoop
Mac 下编译 Hadoop-2.9.2 系统环境 系统: Mac OS_10.14.4 maven: Apache Maven 3.6.0 jdk: jdk_1.8.0_201 ProtocolBu ...
- 【转载】Sqlserver使用Convert函数进行数据类型转换
在Sqlserver数据库中,可以使用Convert函数来进行数据类型的转换,如将数字类型decimal转换为字符串nvarchar类型,或者将字符串类型转换为数字类型都可以使用Convert函数来实 ...
- 了解Scrum敏捷开发过程的优点
Scrum 1. 我们的团队 1.1 团队名称 开发小分队&7号 1.2 团队成员 徐棒 彭康明 刘鹏芝 罗樟 王小莉 胡广健 沈兴艳 1.3 我在团队中位置 需求实现团队(负责将需求模块实现 ...
- VSCode 搭建 React Native 环境
安装 React Native Tools 在插件市场搜索 react 找到 React Native Tools 进行安装: 创建的react-native的工程拖入vscode中 点击F5即可运行 ...
- ble编程-外设发送数据到中心
一.外设 1.在外设的.h文件中定义如下 1 //周边管理者 2 3 @property (nonatomic , strong) CBPeripheralManager *peripheralM ...
- Story of Jerry Wang's Wechat subscription account
As an SAP Techinical Ambassador,Jerry is always willing to share his SAP expertise to various social ...
- iveiw DatePicker 只能选择本月之前的日期,本月包括之后都不能选择
日期判断只能选择本月之前的日期 <DatePicker type="date" :options="options3" format="yyyy ...
- 静态库 VS 动态库
如何得到库 ①先写好一堆的.c文件(.c:我们所需要的各种工具函数) ②将这些.c编译为对应的.o ③将所有的这些.o打包为一个仓库文件(静态库或者动态库) 静态库:按照静态库的方式打包 动态库:按照 ...