In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Mongodb monitoring command
I. Monitoring tools
1. Mongostat tool
The default is to display statistics per second
# mongostat-uroot-ppassword-- authenticationDatabase admin-h292.168.x.xx-- rowcount 10 1connected to: 192.168.x.xxinsert query update delete getmore command flushes mapped vsize res faults locked db idx miss% qr | qw ar | aw netIn netOut conn set repl time * 0 * 0 * 0 * 03 | 0 01.19g 3.07g 85m 0 test:0.0% 0 0 | 0 0 | 0 | 0 178b 4k 6 rs0 SEC 21:02:36 * 0 * 0 * 0 * 003 | 0 01.19g 3.07g 85m 0 test:0.0% 0 | 0 0 | 0 342b 4k 6 rs0 SEC 21:02:37 * 0 * 0 * 0 * 0 01 | 0 01.19g 3 .07g 85m 0 test:0.0% 0 | 0 0 | 062b 3k 6 rs0 SEC 21:02:38 * 0 * 0 * 0 * 0.03 | 0 11.19g 3.07g 85m 0 test:0.0% 00 | 0 0 | 0.342b 4k 6 rs0 SEC 21:02:39 * 0 6 * 0 * 0 01 | 0 01.19g 3.07g 85m 0 test:0.0% 0 | 0 0 | 062b 3k 6 rs0 SEC 21:02:40 * 0 * 0 * 003 | 0.01.19g 3.07g 85m 0 test:0.0% 0 | 0 | 0 | 0 342b 4k 6 rs0 SEC 21:02:41 * 0 * 0 * 0 * 0 01 | 0 01.19g 3.07g 85m 0 test:0.0% 0 0 | 0 0 | 062b 3k 6 rs0 SEC 21:02:42 * 0 * 0 * 0 * 003 | 0 0 | 1.19g 3.07g 85m 0 test:0.0% 0 | 0 | 0 342b 4k 6 rs0 SEC 21:02:43 * 0 * 0 * 0 * 0 01 | 0.01.19g 3.07g 85m 0 test:0.0% 00 | 0 0 | 062b 3k 6 rs0 SEC 21:02:44 * 0 * 0 * 0 * 003 | 0 01.19g 3.07g 85m 0 db4:0.0% 0 | 0 0 | 0 342b 4k 6 rs0 SEC 21:02:45
You can add-- discover to display statistics for all members of the shard cluster (connecting to mongos) and replica sets.
Output meaning, refer to: http://docs.mongodb.org/v2.6/reference/program/mongostat/
2. Mongotop tool
Displays the read and write time of the collection of each database, or the read and write lock time of each database (--locks). The default is 1 second.
# mongotop-uroot-ppassword-- authenticationDatabase admin-h292.168.x.xx 5connected to: 192.168.x.xx ns total read write 2015-06-10T13:23:51 db4.system.indexes 0ms 0ms 0ms db4.$cmd 0ms 0ms 0ms db2.system.namespaces 0ms 0ms 0ms db2.system.indexes 0ms 0ms 0ms db2.post 0ms 0ms 0ms db1.userX2 0ms 0ms 0ms db1.userX1 0ms 0ms 0ms ns total read write 2015-06-10T13:23:56 db4.system.indexes 0ms 0ms 0ms db4.$cmd 0ms 0ms 0ms db2.system.namespaces 0ms 0ms 0ms db2.system.indexes 0ms 0ms 0ms db2.post 0ms 0ms 0ms db1.userX2 0ms 0ms 0ms db1.userX1 0ms 0ms 0ms # mongotop-uroot-ppassword-authenticationDatabase admin-h292.168.x.xx 5-locksconnected to: 192.168.x.xx db total read write 2015-06-10T13:24:42. 1ms 1ms 0ms test 0ms 0ms 0ms local 0ms 0ms 0ms db4 0ms 0ms 0ms db2 0ms 0ms 0ms db1 0ms 0ms 0ms admin 0ms 0ms 0ms db total read write 2015-06-10T13:24:47 test 0ms 0ms 0ms local 0ms 0ms 0ms db4 0ms 0ms 0ms db2 0ms 0ms 0ms db1 0ms 0ms 0ms admin 0ms 0ms 0ms. 0ms 0ms 0ms
Output meaning, refer to: http://docs.mongodb.org/v2.6/reference/program/mongotop/
3. Db.serverStatus ()
Reference: http://docs.mongodb.org/v2.6/reference/command/serverStatus/
4. Db.stats ()
> db.stats () {"db": "db4", "collections": 3, "objects": 13, "avgObjSize": 87.38461538461539, "dataSize": 1136, "storageSize": 24576, "numExtents": 3, "indexes": 3, "indexSize": 24528, "fileSize": 16777216 "nsSizeMB": 16, "dataFileVersion": {"major": 4, "minor": 5}, "extentFreeList": {"num": 0, "totalSize": 0}, "ok": 1}
Reference: http://docs.mongodb.org/v2.6/reference/command/dbStats/#dbcmd.dbStats
5. Db.collect_name.stats ()
{"ns": "db4.userInfo", "count": 5, "size": 560,112 "avgObjSize", "storageSize": 8192, "numExtents": 1, "nindexes": 3, "lastExtentSize": 8192, "paddingFactor": 1, "systemFlags": 1, "userFlags": 1 "totalIndexSize": 24528, "indexSizes": {"_ id_": 8176, "name_hashed": 8176, "age_1": 8176}, "ok": 1}
Reference: http://docs.mongodb.org/v2.6/reference/command/collStats/#dbcmd.collStats
6. Rs.status ()
Query replica set information
> rs.status () {"set": "rs0", "date": ISODate ("2015-06-11T04:02:55Z"), "myState": 2, "syncingTo": "192.168.x.xx:27018", "members": [{"_ id": 0 "name": "192.168.x.xx:27017", "health": 1, "state": 2, "stateStr": "SECONDARY", "uptime": 84674, "optime": Timestamp (1435989328 1), "optimeDate": ISODate ("2015-07-04T05:55:28Z"), "lastHeartbeat": ISODate ("2015-06-11T04:02:54Z"), "lastHeartbeatRecv": ISODate ("2015-06-11T04:02:54Z"), "pingMs": 8 "syncingTo": "192.168.x.xx:27018"}, {"_ id": 3, "name": "192.168.x.xx:27017", "health": 1 "state": 2, "stateStr": "SECONDARY", "uptime": 84676, "optime": Timestamp (1435989328, 1), "optimeDate": ISODate (2015-07-04T05:55:28Z) "self": true}, {"_ id": 4, "name": "192.168.x.xx:27018", "health": 1, "state": 1 StateStr: "PRIMARY", "uptime": 84674, "optime": Timestamp (1435989328, 1), "optimeDate": ISODate ("2015-07-04T05:55:28Z"), "lastHeartbeat": ISODate ("2015-06-11T04:02:54Z") "lastHeartbeatRecv": ISODate ("2015-06-11T04:02:55Z"), "pingMs": 2, "electionTime": Timestamp (1435803779, 1), "electionDate": ISODate ("2015-07-02T02:22:59Z")}], "ok": 1}
Reference: http://docs.mongodb.org/v2.6/reference/command/replSetGetStatus
Second, diagnosing performance problems
1 、 Locks
Analyze the globalLock part of the db.serverStatus () output:
"globalLock": {"totalTime": NumberLong ("240481182000"), "lockTime": NumberLong (11670085), "currentQueue": {"total": 0, "readers": 0, "writers": 0} "activeClients": {"total": 0, "readers": 0, "writers": 0}}
If globalLock.currentQueue.total is consistently high, then there is a chance that a large number of requests are waiting for a lock.
This indicates a possible concurrency issue that may be affecting performance.
GlobalLock.totalTime: The value of totalTime represents the time, in microseconds, since the database last started and creation of the globalLock.
This is roughly equivalent to total server uptime.
The lockTime/totalTime is large, indicating that the lock takes a long time, resulting in performance degradation.
2. Memory
Analyze the mem part of the db.serverStatus () output:
"mem": {"bits": 64, "resident": 39, "virtual": 2993, "supported": true, "mapped": 1119, "mappedWithJournal": 2238}
The unit is M.
Resident represents the memory consumed by the mongodb process, and if it is a dedicated server, the value of this parameter will gradually approach the system memory as the memory used by mongodb increases.
If the value of this parameter exceeds the system memory and a large amount of data is stored on disk rather than in memory, we need to increase the hardware capacity.
The amount of memory mapped by the mapped file, which is roughly the same size as the mongodb database.
If this value is greater than the amount of system memory, some operations will require disk access page faults to read data from virtual memory and negatively affect performance.
3 、 Page Faults
Analyze the extra_info part of the db.serverStatus () output:
"extra_info": {"note": "fields vary by platform", "heap_usage_bytes": 62941696, "page_faults": 40}
Usually, reading a large amount of data will result in a large amount of page faults, which will degrade the performance of mongodb. The solution is to optimize sql or expand memory.
4. Number of connections
Analyze the connections part of the db.serverStatus () output:
"connections": {"current": 12, "available": 1626, "totalCreated": NumberLong (8014)} "globalLock": {"totalTime": NumberLong ("240481182000"), "lockTime": NumberLong (11670085) "currentQueue": {"total": 0, "readers": 0, "writers": 0}, "activeClients": {"total": 0 "readers": 0, "writers": 0}}
Description:
GlobalLock.activeClients contains a counter of the total number of clients with active operations in progress or queued.
Connections is a container for the following two fields:
Current the total number of current clients that connect to the database instance.
Available the total number of unused collections available for new clients.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.