我的boto弹性mapreduce jar作业流参数有什么问题?

时间:2011-01-24 22:57:50

标签: python hadoop boto mahout amazon-emr

我正在使用boto库在Amazons Elastic MapReduce Webservice(EMR)中创建作业流程。以下代码应创建一个步骤:

step2 = JarStep(name='Find similiar items',
            jar='s3n://recommendertest/mahout-core/mahout-core-0.5-SNAPSHOT.jar',
            main_class='org.apache.mahout.cf.taste.hadoop.similarity.item.ItemSimilarityJob',
            step_args=['s3n://bucket/output/' + run_id + '/aggregate_watched/',
                       's3n://bucket/output/' + run_id + '/similiar_items/',
                       'SIMILARITY_PEARSON_CORRELATION'
                      ])

当我运行作业流程时,始终无法抛出此错误:

java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/JobContext
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
at org.apache.hadoop.mapred.JobShell.run(JobShell.java:54)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
at org.apache.hadoop.mapred.JobShell.main(JobShell.java:68)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.mapreduce.JobContext

这是调用java代码的EMR日志中的一行:

2011-01-24T22:18:54.491Z INFO Executing /usr/lib/jvm/java-6-sun/bin/java \
-cp /home/hadoop/conf:/usr/lib/jvm/java-6-sun/lib/tools.jar:/home/hadoop:/home/hadoop \
/hadoop-0.18-core.jar:/home/hadoop/hadoop-0.18-tools.jar:/home/hadoop/lib/*:/home/hadoop/lib/jetty-ext/* \
-Xmx1000m \
-Dhadoop.log.dir=/mnt/var/log/hadoop/steps/3 \
-Dhadoop.log.file=syslog \
-Dhadoop.home.dir=/home/hadoop \
-Dhadoop.id.str=hadoop \
-Dhadoop.root.logger=INFO,DRFA \
-Djava.io.tmpdir=/mnt/var/lib/hadoop/steps/3/tmp \
-Djava.library.path=/home/hadoop/lib/native/Linux-i386-32 \
org.apache.hadoop.mapred.JobShell \
/mnt/var/lib/hadoop/steps/3/mahout-core-0.5-SNAPSHOT.jar \
org.apache.mahout.cf.taste.hadoop.similarity.item.ItemSimilarityJob \
s3n://..../output/job_2011-01-24_23:09:29/aggregate_watched/ \
s3n://..../output/job_2011-01-24_23:09:29/similiar_items/ \
SIMILARITY_PEARSON_CORRELATION

参数有什么问题?可以在这里找到java类定义:

https://hudson.apache.org/hudson/job/Mahout-Quality/javadoc/org/apache/mahout/cf/taste/hadoop/similarity/item/ItemSimilarityJob.html

3 个答案:

答案 0 :(得分:3)

我找到了问题的解决方案:

  1. 您需要在作业流参数
  2. 中指定hadoop版本0.20
  3. 您需要使用mahout-core-0.5-SNAPSHOT-job.jar运行JAR步骤,而不是使用mahout-core-0.5-SNAPSHOT.jar
  4. 如果您的作业流程中还有其他流式处理步骤,则需要修复boto中的错误:
    1. 打开boto / emr / step.py
    2. 将第138行更改为“return”/home/hadoop/contrib/streaming/hadoop-streaming.jar'“
    3. 保存并重新安装boto
  5. 这是应该使用mahout调用job_flow函数的方式:

    jobid = emr_conn.run_jobflow(name = name, log_uri = 's3n://'+ main_bucket_name +'/emr-logging/', enable_debugging=1, hadoop_version='0.20', steps=[step1,step2])

答案 1 :(得分:1)

上面步骤#2中描述的对boto的修复(即使用非版本化的hadoop-streamin.jar文件)已在此提交中合并到github master中:

https://github.com/boto/boto/commit/a4e8e065473b5ff9af554ceb91391f286ac5cac7

答案 2 :(得分:1)

对于一些从boto

执行此操作的参考
import boto.emr.connection as botocon

import boto.emr.step as step

con = botocon.EmrConnection(aws_access_key_id='', aws_secret_access_key='')

step = step.JarStep(name='Find similar items', jar='s3://mahout-core-0.6-job.jar', main_class='org.apache.mahout.cf.taste.hadoop.similarity.item.ItemSimilarityJob', action_on_failure='CANCEL_AND_WAIT', step_args=['--input', 's3://', '--output', 's3://', '--similarityClassname', 'SIMILARITY_PEARSON_CORRELATION'])

con.add_jobflow_steps('jflow', [step])

显然,您需要将mahout-core-0.6-job.jar上传到可访问的s3位置。输入和输出必须是可访问的。