2017-07-06 14 views
0

我想添加一個索引集合(data_04)的OPID,但之後執行它在蒙戈外殼如何找到一個索引構建操作

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?

回答

1

在我的情況下,它應該是

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) 
      } 
     } 
    } 
}