问题
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