What are the common mongodb operation and maintenance monitoring and implementation plans?
This article mainly explains "what are the common operation and maintenance monitoring and implementation plans of mongodb". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what are the common operation and maintenance monitoring and implementation plans of mongodb"?
Query slow requests for more than 3 seconds. Test library needs to be replaced with a specific db name.
Db.currentOp (
{
"active": true
"secs_running": {"$gt": 3}
"ns": / ^ test\. /
}
)
Query all write operations waiting for a lock
Db.currentOp (
{
"waitingForLock": true
$or: [
{"op": {"$in": ["insert", "update", "remove"]}}
{"query.findandmodify": {$exists: true}}
]
}
)
Batch kill slow query
Db.currentOp (
{
"active": true
"microsecs_running": {"$gt": 100}
"ns": / ^ test2\. /
}. Inprog.forEach (
Function (op)
{
Db.killOp (op.opid)
Printjson (op)
}
)
Query requests exceeding 0.1s
Db.currentOp ({secs_running: {$gte: 0.1}})
At this point, I believe you have a deeper understanding of "what are the common operation and maintenance monitoring and implementation plans of mongodb". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!