MongoDB Monitoring Common methods

Source: Internet
Author: User
Tags memory usage mongodb monitoring

Enumerate common commands for MongoDB monitoring

1. Monitoring statistics

Mongostat can be used to view the current qps/memory usage/connection number, as well as the pressure distribution of multiple Shard

Command Reference

./mongostat --port 27071  -u admin -p xxx --authenticationDatabase=admin --discover -n 30 3

Parameter description
-discover provides the status of all nodes in the cluster
-N 30 3 indicates output 30 times, 3 seconds per sleep

Output example

                   insert query update delete getmore command  %dirty  %used flushes mapped vsize   res faults qr|qw  ar|aw netIn netOut conn    set repl                      time185.1.12.101:10001    499  4886   2042   1612     237   756|0     3.8   80.1       0        28.5G 19.1G    n/a   3|0    1|1    4m     7m 5545 shard0  PRI 2017-03-06T11:48:17+08:00

Indicator description

Indicator name Description
inserts/s Number of insertions per second
query/s Number of queries per second
update/s Number of updates per second
delete/s Number of deletions per second
getmore/s Number of Getmore per second
command/s Number of commands per second, including additions and deletions and other operations
dirty/% Wriedtiger engine parameters, percentage of invalid data in cache
used/% Wriedtiger engine parameters, percentage of cache being used
flushs/s Number of times per second that Fsync data is written to the hard disk
Mapped/mb The amount of data that is mmap
Vsize/mb Virtual Memory usage
Res/mb Amount of physical memory used
faults/s Number of access failures per second, related to memory swap
Qrqw Client read-write wait queue number, high concurrency, general queue values will rise
Araw Client read/write active number
Netin Network received data volume
Netout The amount of data sent over the network
Conn Current number of connections
Set Owning collection (shard)
Repl Replication Status (Master node/Level two node ...)
Time Time stamp

Official notes
https://docs.mongodb.com/manual/reference/program/mongostat/

2. Hotspot operation

The mongotop is used to view the current high-occupancy DB operation, which is the hotspot operation.

Command Reference

./mongotop --port 10001  -u admin -p xxx --authenticationDatabase=admin

Output example

    ns                  total   read    write   2017-03-20T15:22:36+08:00    nscl.T_De**ata      407ms   266ms   140ms                                 nscl.T_OAUT**EN     251ms   242ms   8ms                                 nscl.T_Subs**tion   180ms   180ms   0ms                                 nscl.T_De**istory   61ms    0ms     61ms                             

Official notes
https://docs.mongodb.com/manual/reference/program/mongotop/

3. Slow operation detection

Profile is a module for MongoDB to implement slow-action detection, official note

Connecting the shell (using root)

./mongo --port 10001  -u root -p xxx --authenticationDatabase=adminuse admin

Attention
The profile operation must be connected to the Mongod process, and MONGOs cannot perform such operations

Profile settings

db.setProfilingLevel(0) 不输出慢查询db.setProfilingLevel(1,100) 统计慢查询,100ms是阈值db.setProfilingLevel(2) 统计所有操作db.getProfilingLevel()

Query slow Query

db.system.profile.find().limit(10).sort( { ts : -1 } ).pretty() db.system.profile.find().limit(10).sort( { millis : -1 } ).pretty()

Querying the current operation

db.currentOp()
    • Sample-query wait lock additions and deletions

      db.currentOp(   { "waitingForLock" : true, $or: [    { "op" : { "$in" : [ "insert", "update", "remove" ] } },    { "query.findandmodify": { $exists: true } }]   })
    • Example-Querying active query operations

      db.currentOp(true).inprog.forEach(   function(opDoc){ if(!opDoc.active && opDoc.op=='query')    printjson(d) } )

      Currentop More information

4. Set State analysis

Database status

db.stats()->{   "db" : "test",           //当前数据库   "collections" : 3,       //集合数量   "objects" : 165606718,   //对象数量   "avgObjSize" : 381,      //对象平均大小   "dataSize" : 63142130610, //所有数据总大小   "storageSize" : 16384,    //数据占磁盘大小   "numExtents" : 3,   "indexes" : 479,          //索引数   "indexSize" : 8011636736, //索引大小   "fileSize" : 201326592    

Collection State

db.xxx.stats()->   ...    "sharded" : true,      //是否分片    "capped" : false,      //是否限制大小    "ns" : "nscl.T_BUSINESS_LOG",    "count" : 26541837,         //表数量    "size" : 14991828070,       //表大小    "storageSize" : 3615076352, //占磁盘大小    "totalIndexSize" : 2640109568, //索引大小    "avgObjSize" : 564.8376210734773,    "nindexes" : 6,    "nchunks" : 374         //chunk数量   ...

MongoDB Monitoring Common methods

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.