mrjob 返回非零退出状态 256

mrjob returned non-zero exit status 256

我是 map reduce 的新手,我正在尝试 运行 使用 python 的 mrjob 包进行 map reduce 作业。但是,我遇到了这个错误:

ERROR:mrjob.launch:Step 1 of 1 failed: Command '['/usr/bin/hadoop', 'jar', '/usr/lib/hadoop-mapreduce/hadoop-streaming.jar', '-files', 
'hdfs:///user/hadoop/tmp/mrjob/word_count.hadoop.20180831.035452.437014/files/mrjob.zip#mrjob.zip,
hdfs:///user/hadoop/tmp/mrjob/word_count.hadoop.20180831.035452.437014/files/setup-wrapper.sh#setup-wrapper.sh,
hdfs:///user/hadoop/tmp/mrjob/word_count.hadoop.20180831.035452.437014/files/word_count.py#word_count.py', '-archives', 
'hdfs:///user/hadoop/tmp/mrjob/word_count.hadoop.20180831.035452.437014/files/word_count_ccmr.tar.gz#word_count_ccmr.tar.gz', '-D', 
'mapreduce.job.maps=4', '-D', 'mapreduce.job.reduces=4', '-D', 'mapreduce.map.java.opts=-Xmx1024m', '-D', 'mapreduce.map.memory.mb=1200', '-D', 
'mapreduce.output.fileoutputformat.compress=true', '-D', 'mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.BZip2Codec', '-D', 
'mapreduce.reduce.java.opts=-Xmx1024m', '-D', 'mapreduce.reduce.memory.mb=1200', '-input', 'hdfs:///user/hadoop/test-1.warc', '-output', 
'hdfs:///user/hadoop/gg', '-mapper', 'sh -ex setup-wrapper.sh python word_count.py --step-num=0 --mapper', '-combiner', 
'sh -ex setup-wrapper.sh python word_count.py --step-num=0 --combiner', '-reducer', 'sh -ex setup-wrapper.sh python word_count.py --step-num=0 --reducer']' 
returned non-zero exit status 256

我已经尝试 运行在本地使用 python ./word_count.py input/test-1.warc > output 并成功了。

我正在使用

  1. python 2.7.14
  2. Hadoop 2.8.3-amzn-1
  3. pip 18.0
  4. mrjob 0.6.4

有什么想法吗?谢谢!

这是我在 运行mapreduce 作业中的命令。我从 cc-mrjob 存储库中获取它。该文件名为 run_hadoop.sh,我使用 chmod +x run_hadoop.sh

#!/bin/sh

JOB=""
INPUT=""
OUTPUT=""

sudo chmod +x $JOB.py

if [ -z "$JOB" ] || [ -z "$INPUT" ] || [ -z "$OUTPUT" ]; then
    echo "Usage: [=11=] <job> <input> <outputdir>"
    echo "  Run a CommonCrawl mrjob on Hadoop"
    echo
    echo "Arguments:"
    echo "  <job>     CCJob implementation"
    echo "  <input>   input path"
    echo "  <output>  output path (must not exist)"
    echo
    echo "Example:"
    echo "  [=11=] word_count input/test-1.warc  hdfs:///.../output/"
    echo
    echo "Note: don't forget to adapt the number of maps/reduces and the memory requirements"
    exit 1
fi

# strip .py from job name
JOB=${JOB%.py}

# wrap Python files for deployment, cf. below option --setup,
# see for details
# http://pythonhosted.org/mrjob/guides/setup-cookbook.html#putting-your-source-tree-in-pythonpath
tar cvfz ${JOB}_ccmr.tar.gz *.py

# number of maps resp. reduces 
NUM_MAPS=4
NUM_REDUCES=4

if [ -n "$S3_LOCAL_TEMP_DIR" ]; then
    S3_LOCAL_TEMP_DIR="--s3_local_temp_dir=$S3_LOCAL_TEMP_DIR"
else
    S3_LOCAL_TEMP_DIR=""
fi
python $JOB.py \
       -r hadoop \
       --jobconf "mapreduce.map.memory.mb=1200" \
       --jobconf "mapreduce.map.java.opts=-Xmx1024m" \
       --jobconf "mapreduce.reduce.memory.mb=1200" \
       --jobconf "mapreduce.reduce.java.opts=-Xmx1024m" \
       --jobconf "mapreduce.output.fileoutputformat.compress=true" \
       --jobconf "mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.BZip2Codec" \
       --jobconf "mapreduce.job.reduces=$NUM_REDUCES" \
       --jobconf "mapreduce.job.maps=$NUM_MAPS" \
       --setup 'export PYTHONPATH=$PYTHONPATH:'${JOB}'_ccmr.tar.gz#/' \
       --no-output \
       --cleanup NONE \
       $S3_LOCAL_TEMP_DIR \
       --output-dir "$OUTPUT" \
       "hdfs:///user/hadoop/$INPUT"

我运行它和./run_hadoop.sh word_count test-1.warc output

其中

*更新*

我看了一下HUE界面的syslog。还有这个错误

org.apache.hadoop.mapreduce.v2.app.rm.RMContainerAllocator: Could not deallocate container for task attemptId attempt_1536113332062_0001_r_000003_0

这与我遇到的错误有关吗?

我也在地图尝试的标准错误之一中得到了这个

/bin/sh: run_prestart: line 1: syntax error: unexpected end of file

No module named boto3

但是,我在我的 emr 中使用 pip install boto3 安装了 boto3。该模块在 hadoop 中不可用吗?

我是通过关注这个博客才开始工作的

http://benjamincongdon.me/blog/2018/02/02/MapReduce-on-Python-is-better-with-MRJob-and-EMR/

本质上,

您必须在 hadoop 中为运行程序包含一个 .conf 文件。例如mrjob.conf

在该文件中,使用这个

runners:
  hadoop:
    setup:
      - 'set -e'
      - VENV=/tmp/$mapreduce_job_id
      - if [ ! -e $VENV ]; then virtualenv $VENV; fi
      - . $VENV/bin/activate
      - 'pip install boto3'
      - 'pip install warc'
      - 'pip install https://github.com/commoncrawl/gzipstream/archive/master.zip'
    sh_bin: '/bin/bash -x'

并通过引用 run_hadoop.sh

来使用 conf 文件
python $JOB.py \
        --conf-path mrjob.conf \ <---- OUR CONFIG FILE
        -r hadoop \
        --jobconf "mapreduce.map.memory.mb=1200" \
        --jobconf "mapreduce.map.java.opts=-Xmx1024m" \
        --jobconf "mapreduce.reduce.memory.mb=1200" \
        --jobconf "mapreduce.reduce.java.opts=-Xmx1024m" \
        --jobconf "mapreduce.output.fileoutputformat.compress=true" \
        --jobconf "mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.BZip2Codec" \
        --jobconf "mapreduce.job.reduces=$NUM_REDUCES" \
        --jobconf "mapreduce.job.maps=$NUM_MAPS" \
        --setup 'export PYTHONPATH=$PYTHONPATH:'${JOB}'_ccmr.tar.gz#/' \
        --cleanup NONE \
        $S3_LOCAL_TEMP_DIR \
        --output-dir "hdfs:///user/hadoop/$OUTPUT" \
        "hdfs:///user/hadoop/$INPUT"

现在,如果您调用 ./run_hadoop.sh word_count input/test-1.warc output,它应该可以工作!