gpt4 book ai didi

hadoop - 澄清映射任务并减少hadoop中的任务?

转载 作者:可可西里 更新时间:2023-11-01 14:47:13 26 4
gpt4 key购买 nike

我正在阅读 Hadoop:权威指南。在理解一些概念的过程中,我阅读了一些 SO 帖子,这让我同样感到困惑但也很清晰。以下是一些我需要专家意见的观点,以判断它是否正确以及如果不正确会发生什么情况?


让我们假设这是我的 HDFS 在具有一个节点的伪分布式集群中的样子:

/local/path/to/datanode/storage/0/blk_00001  300 MB
/local/path/to/datanode/storage/0/blk_00002 300 MB
/local/path/to/datanode/storage/0/blk_00003 300 MB
/local/path/to/datanode/storage/0/blk_00004 200 MB

我的文件总大小为 1100 MB,它被分成 300 MB 的 block (这是我的 block 大小)。

现在我要开始我的 Mapreduce 作业了:

据我所知,InputFormat(依次拆分文件)决定了 map 的数量。

案例 1:

我有以下设置:拆分大小 mapred.min.split.size=400 MB

总共会有三个 MR 作业。每个将有一个 400 MB 的输入大小来处理。

1) 映射器 1:这意味着第一个 MR 作业将使用 blk_00001 中的 300 MB 和 blk_00002 中的 100 MB,(数据局部性丢失)。

2) 映射器 2: 现在,第二个映射器必须从位置 101 MB blk_00002 和另外 200 MB 的 blk_00003 处寻找

) Mapper 3: blk_0003 上还有 100 MB 和 blk_0004 上的 200 MB 有待处理。现在大小为 300 MB,应整体处理。

block 大小在 MAPRED 任务中没有作用

Q1:到这里一切都正确吗??????


案例 2:

现在假设我的 MR 工作有以下设置:mapred.tasktracker.map.tasks.maximum=3。这意味着对于任何给定节点,并行运行三个映射任务。

Q2:如果上面的所有映射器都在同一节点上并行运行,它们是在具有相似优先级的不同线程中运行,还是在 CPU 级别的单独进程中运行。


案例 3:如果我在 conf.setNumMapTasks(int num) 中的 num 大于拆分数。也就是说,我有 num = 10,拆分数 = 3。将要执行的 MR 作业总数为 3。

**Q3:**正确??


Reducer 任务:

Q4 mapper 必须在 reducer 启动之前完成 - 据我所知,在所有情况下,任何示例都不会。因为键需要排序并按顺序交给 reducers。

Q5那么mapred.reduce.slowstart.completed.maps=0.5的作用是什么。这意味着当 map 任务完成 50% 时,启动 reducer。但是 reducer 需要 map 作业才能完成。对吗???

2) 如果我不指定任何东西,reducer 的默认数量是多少。

已经proposed使用 0.95 - 1.75 * (nodes * mapred.tasktracker.tasks.maximum)。所以如果我有 5 个节点的集群,每个节点有 5 个核心,公式给出 (0.95 * 5 * 5) = 24 reducers 。

那么我应该设置 conf.setNumReduceTasks(24) 吗????

最佳答案

Q1: Is everything correct till here???????

这取决于输入格式。 FileInputFormat 不会进行小于 block 大小的拆分,无论您将最小拆分大小设置为多少。以下是计算拆分大小的代码。

protected long computeSplitSize(long goalSize, long minSize, long blockSize) {
return Math.max(minSize, Math.min(goalSize, blockSize));
}

Q2: If all the mappers above runs parallel on same node, do they run in different Threads with similar priority or a separate process at CPU level.

每个任务都在自己的环境中运行 Java virtual machine , 所以分开进程。

Q3: if my num in conf.setNumMapTasks(int num) is greater than number of splits. That is say, I have num = 10 and the number of splits = 3. The total MR job that will be executed is 3.

setNumMapTasks()not supported anymore并且仅作为对 MapReduce 系统的提示。

Q4: A mapper has to finish before the reducer starts - in all cases to my knowledge, any examples where it will not be. because the keys need sorting and handed them in order to reducers.

Q5 so what is the effect of mapred.reduce.slowstart.completed.maps=0.5. This would mean when the map task is 50% complete, start the reducers. but the reducer needs map jobs to be complete. correct???

慢启动涉及将数据复制到适当的机器。在所有映射器完成之前,reducer 中的 reduce() 方法不会被调用。

what is the default number of reducers if I don't specify anything.

1

so should I set conf.setNumReduceTasks(24)????

最适合您的任务。

关于hadoop - 澄清映射任务并减少hadoop中的任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24618037/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com