查看长期运行的mongodb聚合作业的进度 [英] View progress of long running mongodb aggregation job

查看:263
本文介绍了查看长期运行的mongodb聚合作业的进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Mongodb的(2.6.0-rc2)聚合框架执行了很长时间: http ://docs.mongodb.org/manual/core/aggregation-introduction/

I have a long running job using Mongodb's (2.6.0-rc2) aggregation framework: http://docs.mongodb.org/manual/core/aggregation-introduction/

我已使用javascript编写了汇总,并以脚本的形式运行了作业
(即mongo localhost:27017/test myjsfile.js).
启动脚本后,有什么方法可以查看工作进度吗?

I have written the aggregation in javascript and run the job as a script
(i.e. mongo localhost:27017/test myjsfile.js).
After starting the script, is there any way to see the progress of the job?

例如,使用示例聚合作业:

For example, using the sample aggregation job:

db.zipcodes.aggregate([
    {$group: {
        _id: "$state",
        totalPop: {$sum: "$pop"}
    }},
    {$match: {totalPop: {$gte: 10*1000*1000 }}}
])

我希望看到该工作目前正在小组进行,并且完成了70%.

I would like to see that the job is currently performing a group and is 70% done.

对于mongo的mapreduce作业,您可以通过db.currentOp()查看进度,如该帖子所述,它具有一个progress字段,该字段显示已完成作业的百分比:

For mongo's map reduce jobs, you can view progress via db.currentOp(), which has a progress field that shows the percentage of the job that is complete, as outlined in this post:

是否可以缩小地图进度通知是否在mongo中?

聚合有什么相似之处吗?

Is there anything similar for aggregate?

推荐答案

如果使用

If you use the $out aggregation pipeline operator to output the result of the aggregation to another (or the same) collection, you can open a new mongo shell and see how many documents are in the new collection. If you're overwriting the collection you're aggregating from, MongoDB will use a temporary collection name in order to make the operation atomic, like tmp.agg_out.1. So, run

db['tmp.agg_out.1'].count()

要找出临时集合的确切名称,您可以在当前的MongoDB后面加上 log ,并查看有关聚合的消息. mLab和其他云MongoDB托管提供商也可以使用方便的流当前日志"选项.

To find out the exact name of the temporary collection, you can tail the current MongoDB log and watch for messages about the aggregation. mLab and other cloud MongoDB hosting providers may have a handy "stream current log" option as well.

例如,在此答案中运行查询时,,相关的日志消息可能如下所示:

For example, while running the query in this answer, the relevant log messages may look like this:

2019-04-05T03:55:42.126-0700我COMMAND [conn244209]命令 collection.tmp.agg_out.1 appName:"MongoDB Shell"命令:insert {插入:"tmp.agg_out .1,已排序:true,$ db:"mydb"}插入:18145 keysInserted:351002 numYields:0锁:{全局:{acquisitionCount:{r:70917,w:61737}},数据库:{...} ,集合:{...},元数据:{...},操作日志:{...}协议:op_msg 161451ms

2019-04-05T03:55:42.126-0700 I COMMAND [conn244209] command collection.tmp.agg_out.1 appName: "MongoDB Shell" command: insert { insert: "tmp.agg_out.1", ordered: true, $db: "mydb" } ninserted:18145 keysInserted:351002 numYields:0 locks:{ Global: { acquireCount: { r: 70917, w: 61737 } }, Database: { ... }, Collection: { ... }, Metadata: { ... }, oplog: { ... } protocol:op_msg 161451ms

(我希望 nInserted keysInserted 将表示进度,但事实并非如此;临时集合中文档的数量是一个更为准确的进度指示器.)

(I was hoping that nInserted or keysInserted would indicate progress, but that doesn't seem to be the case; the count of the documents in the temporary collection was a much more accurate progress indicator.)

这篇关于查看长期运行的mongodb聚合作业的进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆