检查正在运行的MongoDB MapReduce作业的状态 [英] Check status of running MongoDB map reduce jobs
问题描述
如何检查Mongo DB中正在运行的map reduce作业的状态?我的代码可以运行Mongo map reduce作业,但是我想要一个状态表,将作业列为进行中"或完成".我如何从Mongo DB获得该信息?
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?
推荐答案
您可以使用db.currentOp()查询所有正在运行的作业.
You can query for all running jobs using db.currentOp().
通常,Map/Reduce作业具有一些可查询的属性.
Usualy a Map/Reduce job has a few attributes you can query for.
我刚刚完成的一项M/R工作具有以下统计信息:
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
},
...
这就是您应该寻找的!尤其是"msg"属性,它表示M/R进展如何.
That's what you should look for! Especialy the "msg" attribute, that says how's the M/R progress.
这篇关于检查正在运行的MongoDB MapReduce作业的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!