查看MongoDB正在执行哪些操作
rs1:PRIMARY> db.currentOp()
{
"inprog" : [
{
"desc" : "conn111911",
"threadId" : "140075999385344",
"connectionId" : 111911,
"client" : "10.62.124.34:37476",
"clientMetadata" : {
"driver" : {
"name" : "NetworkInterfaceASIO-RS",
"version" : "3.4.9"
},
"os" : {
"type" : "Linux",
"name" : "CentOS Linux release 7.4.1708 (Core) ",
"architecture" : "x86_64",
"version" : "Kernel 3.10.0-693.el7.x86_64"
}
},
"active" : true,
"opid" : 757162244,
"secs_running" : 2,
"microsecs_running" : NumberLong(2386307),
"op" : "getmore",
"ns" : "local.oplog.rs",
"query" : {
"getMore" : NumberLong("12928643803"),
"collection" : "oplog.rs",
"maxTimeMS" : NumberLong(5000),
"term" : NumberLong(313),
"lastKnownCommittedOpTime" : {
"ts" : Timestamp(1516859517, 1),
"t" : NumberLong(313)
}
},
"originatingCommand" : {
"find" : "oplog.rs",
"filter" : {
"ts" : {
"$gte" : Timestamp(1516755142, 1)
}
},
"tailable" : true,
"oplogReplay" : true,
"awaitData" : true,
"maxTimeMS" : NumberLong(60000),
"term" : NumberLong(313)
},
"planSummary" : "COLLSCAN",
"numYields" : 0,
"locks" : {
},
"waitingForLock" : false,
"lockStats" : {
"Global" : {
"acquireCount" : {
"r" : NumberLong(2)
}
},
"Database" : {
"acquireCount" : {
"r" : NumberLong(1)
}
},
"oplog" : {
"acquireCount" : {
"r" : NumberLong(1)
}
}
}
}
],
"ok" : 1
}
"desc" : "conn111911",#数据库的连接信息,可与日志信息联系起来,可以用来筛选相关的日志信息。"threadId" : "140075999385344",#线程ID
"connectionId" : 111911,数据库的连接ID
"client" : "10.62.124.34:37476",#连接的客户端信息
"clientMetadata" : {
"driver" : {
"name" : "NetworkInterfaceASIO-RS",
"version" : "3.4.9"
},
"os" : {
"type" : "Linux",
"name" : "CentOS Linux release 7.4.1708 (Core) ",
"architecture" : "x86_64",
"version" : "Kernel 3.10.0-693.el7.x86_64"
}
},
"active" : true,#是否活动状态,true表示当前正在运行,false表示此操作已交出或在等待其他操作交出锁
"opid" : 757162244,#操作的唯一标识符,可通过它来终止操作
"secs_running" : 2,#查看执行时间,可以通过该参数定位耗时的操作
"microsecs_running" : NumberLong(2386307),
"op" : "getmore",#操作类型,包括(insert/query/update/remove/getmore/command)
"ns" : "local.oplog.rs",#命名空间
"query" : {#如果op是查询操作,这里将显示查询内容;也有说这里显示具体的操作语句的
"getMore" : NumberLong("12928643803"),
"collection" : "oplog.rs",
"maxTimeMS" : NumberLong(5000),
"term" : NumberLong(313),
"lastKnownCommittedOpTime" : {
"ts" : Timestamp(1516859517, 1),
"t" : NumberLong(313)
}
},
"originatingCommand" : {
"find" : "oplog.rs",
"filter" : {
"ts" : {
"$gte" : Timestamp(1516755142, 1)
}
},
"tailable" : true,
"oplogReplay" : true,
"awaitData" : true,
"maxTimeMS" : NumberLong(60000),
"term" : NumberLong(313)
},
"planSummary" : "COLLSCAN",
"numYields" : 0,#表示该操作交出锁,而使其他操作得以运行
"locks" : {
},
"waitingForLock" : false,#表示该操作是否因正在等待其他操作交出锁而处于阻塞状态。
"lockStats" : {
"Global" : {
"acquireCount" : {
"r" : NumberLong(2)
}
},
"Database" : {
"acquireCount" : {
"r" : NumberLong(1)
}
},
"oplog" : {
"acquireCount" : {
"r" : NumberLong(1)
}
}
}
参考:https://docs.mongodb.com/manual/reference/method/db.currentOp/index.html