mongodb - 查看正在执行的操作

查看正在执行的操作
db.currentOp()

查看系统执行的操作
db.currentOp(True)

kill正在执行的操作
db.killOp()

 

示例:

> db.currentOp().inprog
[
        {
                "desc" : "conn15",
                "threadId" : "140563298641664",
                "connectionId" : 15,
                "client" : "127.0.0.1:22588",
                "active" : true,
                "opid" : 12993394,
                "secs_running" : 0,
                "microsecs_running" : NumberLong(38),
                "op" : "command",
                "ns" : "admin.$cmd",
                "query" : {
                        "currentOp" : 1
                },
                "numYields" : 0,
                "locks" : {

                },
                "waitingForLock" : false,
                "lockStats" : {

                }
        },
        {
                "desc" : "conn14",
                "threadId" : "140563612096256",
                "connectionId" : 14,
                "client" : "127.0.0.1:22587",
                "active" : true,
                "opid" : 12993385,
                "secs_running" : 6,
                "microsecs_running" : NumberLong(6466243),
                "op" : "command",
                "ns" : "test.$cmd",
                "query" : {
                        "createIndexes" : "currentOpTest",
                        "indexes" : [
                                {
                                        "ns" : "test.currentOpTest",
                                        "key" : {
                                                "i" : 1
                                        },
                                        "name" : "i_1",
                                        "background" : 1
                                }
                        ]
                },
                "msg" : "Index Build (background) Index Build (background): 608127/9999999 6%",
                "progress" : {
                        "done" : 608127,
                        "total" : 9999999
                },
                "numYields" : 4767,
                "locks" : {
                        "Global" : "w",
                        "Database" : "w",
                        "Collection" : "w"
                },
                "waitingForLock" : false,
                "lockStats" : {
                        "Global" : {
                                "acquireCount" : {
                                        "r" : NumberLong(4768),
                                        "w" : NumberLong(4768)
                                }
                        },
                        "Database" : {
                                "acquireCount" : {
                                        "w" : NumberLong(4768),
                                        "W" : NumberLong(1)
                                }
                        },
                        "Collection" : {
                                "acquireCount" : {
                                        "w" : NumberLong(4768)
                                }
                        }
                }
        }
]
> 

 

你可能感兴趣的:(mongodb - 查看正在执行的操作)