Index
查看目前正在執行的後台索引作業 (MongoDB)
在
mongodb.log
我看到2016-03-31T12:44:11.003+0200 I - [conn58191] Index Build (background): 14396400/17648149 81% 2016-03-31T12:44:14.018+0200 I - [conn58191] Index Build (background): 14414100/17648154 81% 2016-03-31T12:44:17.008+0200 I - [conn58191] Index Build (background): 14439300/17648155 81% 2016-03-31T12:44:20.009+0200 I - [conn58191] Index Build (background): 14467800/17648159 81% 2016-03-31T12:44:23.003+0200 I - [conn58191] Index Build (background): 14492700/17648161 82% 2016-03-31T12:44:26.003+0200 I - [conn58191] Index Build (background): 14520500/17648166 82% 2016-03-31T12:44:29.003+0200 I - [conn58191] Index Build (background): 14551500/17648166 82% 2016-03-31T12:44:32.012+0200 I - [conn58191] Index Build (background): 14571300/17648170 82% 2016-03-31T12:44:35.001+0200 I - [conn58191] Index Build (background): 14584100/17648171 82% 2016-03-31T12:44:38.008+0200 I - [conn58191] Index Build (background): 14600100/17648174 82% 2016-03-31T12:44:41.004+0200 I - [conn58191] Index Build (background): 14619700/17648178 82% 2016-03-31T12:44:44.005+0200 I - [conn58191] Index Build (background): 14641700/17648184 82% 2016-03-31T12:44:47.094+0200 I - [conn58191] Index Build (background): 14665900/17648185 83% 2016-03-31T12:44:50.004+0200 I - [conn58191] Index Build (background): 14685600/17648188 83% 2016-03-31T12:44:53.002+0200 I - [conn58191] Index Build (background): 14700800/17648188 83%
我希望在 mongo shell 中看到這個。我也想看看是哪個索引。
我用Google搜尋發現
db.currentOp( { $or: [ { op: "query", "query.createIndexes": { $exists: true } }, { op: "insert", ns: /\.system\.indexes\b/ } ] } )
但是這個查詢只給出
{ "inprog" : [ ], "ok" : 1 }
我希望看到所有細節。
上週我注意到了同樣的事情。有時,mongo shell 返回任何空數組:
- 嘗試多次執行 currentOp() 以獲得進度。
- 使用use db命令,然後執行 db.currentOp()
我發現這個命令有助於顯示索引進度:
db.currentOp().inprog.map(a => a.msg) [ undefined, undefined, undefined, undefined, undefined, undefined, "Index Build: scanning collection Index Build: scanning collection: 16448156/54469342 30%", undefined, undefined ]