Check status of running MongoDB map reduce jobs

三世轮回 提交于 2019-12-11 11:09:40

问题


How do I check on the status of running map reduce jobs in Mongo DB? My code can run Mongo map reduce jobs, but I'd like to have a status table, listing jobs as "in progress" or "complete". How do I get that information from Mongo DB?


回答1:


You can query for all running jobs using db.currentOp().

Usualy a Map/Reduce job has a few attributes you can query for.

A M/R job I just ran had the following stats:

"opid" : 258101377,
"active" : true,
"secs_running" : 4638,
"op" : "query",
"ns" : "<database>.<collectionname>",
"query": {
    "mapreduce": "<collectionname>",
    "map": function <randomname>() { ... },
    "reduce": function <randomname>(k, v) { ... },
    "out": { ... }
}
"msg":  "m/r: (1/3) emit phase 1235099/11558528 10%",
"progress" : {
    "done" : 1235099,
    "total" : 11558528
},
...

That's what you should look for! Especialy the "msg" attribute, that says how's the M/R progress.



来源:https://stackoverflow.com/questions/11089664/check-status-of-running-mongodb-map-reduce-jobs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!