mapreduce问题记录

博客讨论了在MapReduce任务中,因map阶段长时间无输出导致任务超时的问题。分析指出,超时默认设置为600000ms,可通过调整`mapred.task.timeout`参数来增大超时时间。但建议避免设置过大的值,以防机器故障导致长时间未被发现。最佳实践是确保map阶段定时输出,以防止任务超时。解决方案包括优化代码以增加输出频率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在mapreduce中调用c++的binary进行分词

# -*- coding:utf-8 -*-

import sys
import os
from collections import defaultdict

def main():
    # 收集map的输入
    with open("input.txt", "w", encoding="utf-8") as fout:
        for line in sys.stdin:
            fout.write(line)
    # 调用binary分词
    os.system("/workdir/seg_binary /workdir/word2cnt.txt input.txt output.txt")
    # 输出到stdout
    with open("output.txt", "r", encoding="utf-=8") as fin:
        for line in fin:
            print(line.strip())


if __name__ == '__main__':
    main()

mapred.task.timeout

问题:由于map长时间没有输出,导致mapreduce任务挂掉
分析:控制超时的属性是:mapred.task.timeout,默认600000ms,即10min;
mapred.task.timeout解释:The number of milliseconds before a task will be terminated if it neither reads an input, writes an output, nor updates its status string. A value of 0 disables the timeout.
MR原理:如果监测到有一个task_attempt没有在规定的时间间隔内(mapreduce.task.timeout)汇报进度,那么就认为该attempt已经失败,并发送一个TA_TIMED_OUT的Event,通知ApplicationMaster去Kill掉该Attempt
解决方案

  1. 将mapred.task.timeout调大;
    建议不要调的过大,如果设成1小时,那么假如作业运行的时候某台机器挂了,那也要等到1小时后才能发现进行异常处理。
  2. 确保map每隔一段时间就会有输出,优先考虑

参考链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值