转载

MongoDB监控总结

    说句实话,一直对mongodb没有什么好感.
    硬着头皮弄吧.

版本:mongodb 3.0 (2.6.x副本集有内存泄漏的问题)
引擎:MMAP

http://docs.mongodb.org/v3.0/administration/monitoring/

1.mongostat
MongoDB监控总结

字段解释
http://docs.mongodb.org/v3.0/reference/program/mongostat/#bin.mongostat

locked字段已经没有了
内存映射引擎使用集合锁代替数据库级别的读写锁.
而WiredTiger存储引擎则直接使用文档锁.
这是mongodb3.0的显著改进之一.

Fields

mongostat returns values that reflect the operations over a 1 second period. When mongostat <sleeptime> has a value greater than 1, mongostat averages the statistics to reflect average operations per second.

mongostat outputs the following fields:

inserts

The number of objects inserted into the database per second. If followed by an asterisk (e.g. *), the datum refers to a replicated operation.

query

The number of query operations per second.

update

The number of update operations per second.

delete

The number of delete operations per second.

getmore

The number of get more (i.e. cursor batch) operations per second.

command

The number of commands per second. On slave and secondary systems, mongostat presents two values separated by a pipe character (e.g. |), in the form of local|replicated commands.

flushes

Changed in version 3.0.0.

For the WiredTiger Storage Engine, flushes refers to the number of WiredTiger checkpoints triggered between each polling interval.

For the MMAPv1 Storage Engine, flushes represents the number of fsync operations per second.

dirty

New in version 3.0.0.

Only for WiredTiger Storage Engine. The percentage of the WiredTiger cache with dirty bytes.

used

New in version 3.0.0.

Only for WiredTiger Storage Engine. The percentage of the WiredTiger cache that is in use.

mapped

Changed in version 3.0.0.

Only for MMAPv1 Storage Engine. The total amount of data mapped in megabytes. This is the total data size at the time of the last mongostat call.

vsize

The amount of virtual memory in megabytes used by the process at the time of the last mongostat call.

non-mapped

Changed in version 3.0.0.

Only for MMAPv1 Storage Engine.

Optional. The total amount of virtual memory excluding all mapped memory at the time of the lastmongostat call.

mongostat only returns this value when started with the --all option.

res

The amount of resident memory in megabytes used by the process at the time of the last mongostatcall.

faults

Changed in version 3.0.0.

Only for MMAPv1 Storage Engine. The number of page faults per second.

Changed in version 2.1: Before version 2.1, this value was only provided for MongoDB instances running on Linux hosts.

locked

Changed in version 3.0.0: Only appears when mongostat runs against pre-3.0 versions of MongoDB instances.

The percent of time in a global write lock.

Changed in version 2.2: The locked db field replaces the locked % field to more appropriate data regarding the database specific locks in version 2.2.

idx miss

Changed in version 3.0.0.

Only for MMAPv1 Storage Engine. The percent of index access attempts that required a page fault to load a btree node. This is a sampled value.

qr

The length of the queue of clients waiting to read data from the MongoDB instance.

qw

The length of the queue of clients waiting to write data from the MongoDB instance.

ar

The number of active clients performing read operations.

aw

The number of active clients performing write operations.

netIn

The amount of network traffic, in bytes, received by the MongoDB instance.

This includes traffic from mongostat itself.

netOut

The amount of network traffic, in bytes, sent by the MongoDB instance.

This includes traffic from mongostat itself.

conn

The total number of open connections.

set

The name, if applicable, of the replica set.

repl

The replication status of the member.

2.mongotop
MongoDB监控总结

Fields

mongotop returns time values specified in milliseconds (ms.)

mongotop only reports active namespaces or databases, depending on the --locks option. If you don’t see a database or collection, it has received no recent activity. You can issue a simple operation in the mongo shell to generate activity to affect the output of mongotop.

mongotop.ns

Contains the database namespace, which combines the database name and collection.

Changed in version 2.2: If you use the mongotop --locks, the ns field does not appear in the mongotopoutput.

mongotop.db

New in version 2.2.

Contains the name of the database. The database named . refers to the global lock, rather than a specific database.

This field does not appear unless you have invoked mongotop with the --locks option.

mongotop.total

Provides the total amount of time that this mongod spent operating on this namespace.

mongotop.read

Provides the amount of time that this mongod spent performing read operations on this namespace.

mongotop.write

Provides the amount of time that this mongod spent performing write operations on this namespace.

mongotop.<timestamp>

Provides a time stamp for the returned data.

3.db.currentOp() 命令行终端
MongoDB监控总结

Output Fields

currentOp.desc

A description of the client. This string includes the connectionId.

currentOp.threadId

An identifier for the thread that handles the operation and its connection.

currentOp.connectionId

An identifier for the connection where the operation originated.

currentOp.opid

The identifier for the operation. You can pass this value to db.killOp() in the mongo shell to terminate the operation.

WARNING

Terminate running operations with extreme caution. Only use db.killOp() to terminate operations initiated by clients and do not terminate internal database operations.

currentOp.active

A boolean value specifying whether the operation has started. Value is true if the operation has started or false if the operation is idle, such as an idle connection or an internal thread that is currently idle. An operation can be active even if the operation has yielded to another operation.

Changed in version 3.0: For some inactive background threads, such as an inactivesignalProcessingThread, MongoDB suppresses various empty fields.

currentOp.secs_running

The duration of the operation in seconds. MongoDB calculates this value by subtracting the current time from the start time of the operation.

Only appears if the operation is running; i.e. if active is true.

currentOp.microsecs_running

New in version 2.6.

The duration of the operation in microseconds. MongoDB calculates this value by subtracting the current time from the start time of the operation.

Only appears if the operation is running; i.e. if active is true.

currentOp.op

A string that identifies the type of operation. The possible values are:

  • "none"
  • "update"
  • "insert"
  • "query"
  • "getmore"
  • "remove"
  • "killcursors"

"query" operations include read operations as well as most commands such as the createIndexescommand and the findandmodify command.

Changed in version 3.0: Write operations that use the insertupdate, and delete commands respectively display "insert""update", and "delete" for op. Previous versions include these write commands under "query" operations.

currentOp.ns

The namespace the operation targets. A namespace consists of the database name and the collectionname concatenated with a dot (.); that is, "<database>.<collection>".

currentOp.insert

Contains the document to be inserted for operations with op value of "insert". Only appears for operations with op value "insert".

Insert operations such as db.collection.insert() that use the insert command will have opvalue of "query".

currentOp.query

A document containing information on operations whose op value is not "insert". For instance, for adb.collection.find() operation, the query contains the query predicate.

query does not appear for op of "insert"query can also be an empty document.

For "update" or "remove" operations or for read operations categorized under "query", the querydocument contains the query predicate for the operations.

Changed in version 3.0.4: For "getmore" operations on cursors returned from adb.collection.find() or a db.collection.aggregate(), the query field contains respectively the query predicate or the issued aggregate command document. For details on theaggregate command document, see the aggregate reference page.

For other commands categorized under "query"query contains the issued command document. Refer to the specific command reference page for the details on the command document.

Changed in version 3.0: Previous versions categorized operations that used write commands under opof "query" and returned the write command information (e.g. query predicate, update statement, and update options) in query document.

currentOp.planSummary

A string that contains the query plan to help debug slow queries.

currentOp.client

The IP address (or hostname) and the ephemeral port of the client connection where the operation originates. If your inprog array has operations from many different clients, use this string to relate operations to clients.

currentOp.locks

Changed in version 3.0.

The locks document reports the type and mode of locks the operation currently holds. The possible lock types are as follows:

  • Global represents global lock.
  • MMAPV1Journal represents MMAPv1 storage engine specific lock to synchronize journal writes; for non-MMAPv1 storage engines, the mode for MMAPV1Journal is empty.
  • Database represents database lock.
  • Collection represents collection lock.
  • Metadata represents metadata lock.
  • oplog represents lock on the oplog.

The possible modes are as follows:

  • R represents Shared (S) lock.
  • W represents Exclusive (X) lock.
  • r represents Intent Shared (IS) lock.
  • w represents Intent Exclusive (IX) lock.
currentOp.waitingForLock

Returns a boolean value. waitingForLock is true if the operation is waiting for a lock and false if the operation has the required lock.

currentOp.msg

The msg provides a message that describes the status and progress of the operation. In the case of indexing or mapReduce operations, the field reports the completion percentage.

currentOp.progress

Reports on the progress of mapReduce or indexing operations. The progress fields corresponds to the completion percentage in the msg field. The progress specifies the following information:

currentOp.progress.done

Reports the number completed.

currentOp.progress.total

Reports the total number.

currentOp.killPending

Returns true if the operation is currently flagged for termination. When the operation encounters its next safe termination point, the operation will terminate.

currentOp.numYields

numYields is a counter that reports the number of times the operation has yielded to allow other operations to complete.

Typically, operations yield when they need access to data that MongoDB has not yet fully read into memory. This allows other operations that have data in memory to complete quickly while MongoDB reads in data for the yielding operation.

currentOp.fsyncLock

Specifies if database is currently locked for fsync write/snapshot.

Only appears if locked; i.e. if fsyncLock is true.

currentOp.info

Information regarding how to unlock database from db.fsyncLock(). Only appears if fsyncLock istrue.

currentOp.lockStats

For each lock type and mode (see currentOp.locks for descriptions of lock types and modes), returns the following information:

currentOp.lockStats.acquireCount

Number of times the operation acquired the lock in the specified mode.

currentOp.lockStats.acquireWaitCount

Number of times the operation had to wait for the acquireCount lock acquisitions because the locks were held in a conflicting mode. acquireWaitCount is less than or equal toacquireCount.

currentOp.lockStats.timeAcquiringMicros

Cumulative time in microseconds that the operation had to wait to acquire the locks.

timeAcquiringMicros divided by acquireWaitCount gives an approximate average wait time for the particular lock mode.

currentOp.lockStats.deadlockCount

Number of times the operation encountered deadlocks while waiting for lock acquisitions.

4.db.serverStatus()

字段解释
http://docs.mongodb.org/v3.0/reference/server-status/

5.db.stats()
MongoDB监控总结

Output

dbStats.db

Contains the name of the database.

dbStats.collections

Contains a count of the number of collections in that database.

dbStats.objects

Contains a count of the number of objects (i.e. documents) in the database across all collections.

dbStats.avgObjSize

The average size of each document in bytes. This is the dataSize divided by the number of documents.

dbStats.dataSize

The total size in bytes of the data held in this database including the padding factor. The scaleargument affects this value. The dataSize will not decrease when documents shrink, but will decrease when you remove documents.

dbStats.storageSize

The total amount of space in bytes allocated to collections in this database for document storage. Thescale argument affects this value. The storageSize does not decrease as you remove or shrink documents.

dbStats.numExtents

Contains a count of the number of extents in the database across all collections.

dbStats.indexes

Contains a count of the total number of indexes across all collections in the database.

dbStats.indexSize

The total size in bytes of all indexes created on this database. The scale arguments affects this value.

dbStats.fileSize

The total size in bytes of the data files that hold the database. This value includes preallocated space and the padding factor. The value of fileSize only reflects the size of the data files for the database and not the namespace file.

The scale argument affects this value. Only present when using the mmapv1 storage engine.

dbStats.nsSizeMB

The total size of the namespace files (i.e. that end with .ns) for this database. You cannot change the size of the namespace file after creating a database, but you can change the default size for all new namespace files with the nsSize runtime option.

Only present when using the mmapv1 storage engine.

SEE ALSO

The nsSize option, and Maximum Namespace File Size

dbStats.dataFileVersion

New in version 2.4.

Document that contains information about the on-disk format of the data files for the database. Only present when using the mmapv1 storage engine.

dbStats.dataFileVersion.major

New in version 2.4.

The major version number for the on-disk format of the data files for the database. Only present when using the mmapv1 storage engine.

dbStats.dataFileVersion.minor

New in version 2.4.

The minor version number for the on-disk format of the data files for the database. Only present when using the mmapv1 storage engine.

dbStats.extentFreeList

New in version 3.0.0.

dbStats.extentFreeList.num

New in version 3.0.0.

Number of extents in the freelist. Only present when using the mmapv1 storage engine.

dbStats.extentFreeList.size

New in version 3.0.0.

Total size of the extents on the freelist.

The scale argument affects this value. Only present when using the mmapv1 storage engine.

6.db.<collection>.stats();
MongoDB监控总结

类似于dbstats

7.replSetGetStatus (rs.status())
查看副本集健康情况.
http://docs.mongodb.org/manual/reference/command/replSetGetStatus/

use admin
db.runCommand( { replSetGetStatus : 1 } ) 


正文到此结束
Loading...