我想为集合添加索引(data_04
),但是在mongo shell中执行它之后
mongos> db.data_04.createIndex({"column1":1, "column":1,cacheDataTime:1 })
但经过相当长的一段时间,它仍然没有完成。所以我想明确地杀死它并在后台创建它。但我首先应该知道它的opid
,我尝试了以下方式所有没有输出
# The following example returns information on index creation operations:
mongos> db.currentOp(
... {
... $or: [
... { op: "query", "query.createIndexes": { $exists: true } },
... { op: "insert", ns: /\.system\.indexes\b/ }
... ]
... }
... )
"inprog" : [ ],
"ok" : 1
mongos> db.currentOp(
... {
... "active" : true,
... "ns" : /data_04/
... }
... )
"inprog" : [ ],
"ok" : 1
那么错误以及如何找到索引创建操作的opid?
答案 0 :(得分:2)
就我而言,它应该是
db.currentOp(
{
$or: [
{ op: "command", "query.createIndexes": { $exists: true } },
{ op: "insert", ns: /\.system\.indexes\b/ }
]
}
)
{
"desc" : "conn292",
"threadId" : "140288792557312",
"connectionId" : 292,
"client_s" : "10.47.50.216:39380",
"active" : true,
"opid" : "shard1:2005849",
"secs_running" : 42,
"microsecs_running" : NumberLong(42991403),
"op" : "command",
"ns" : "mydata.$cmd",
"query" : {
"createIndexes" : "data_04",
"indexes" : [
{
"key" : {
"column1" : 1,
"column" : 1,
"cacheDataTime" : 1
},
"name" : "column1_1_column_1_cacheDataTime_1",
"background" : true
}
]
},
"msg" : "Index Build (background) Index Build (background): 41209/1447644 2%",
"progress" : {
"done" : 41209,
"total" : 1447644
},
"numYields" : 1369,
"locks" : {
"Global" : "w",
"Database" : "w",
"Collection" : "w"
},
"waitingForLock" : false,
"lockStats" : {
"Global" : {
"acquireCount" : {
"r" : NumberLong(1370),
"w" : NumberLong(1370)
}
},
"Database" : {
"acquireCount" : {
"w" : NumberLong(1370),
"W" : NumberLong(1)
}
},
"Collection" : {
"acquireCount" : {
"w" : NumberLong(1370)
}
}
}
}