使用python的hadoop流媒体

bqucvtff  于 2021-06-02  发布在  Hadoop
关注(0)|答案(1)|浏览(364)

我正在尝试执行map reduce代码,如下所示:

hadoop jar /usr/lib/Hadoop/Hadoop-streaming-0.20.2-cdh3u2.jar –file mapper.py –mapper mapper.py –file reducer.py – reducer reducer.py –input /user/training/samplypy.txt –ouput  /user/training/pythonMR/output

低于异常-

Exception in thread "main" java.lang.ClassNotFoundException: –file
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:149)

我正在使用hadoop1.0.3。我试过使用多个版本的hadoop流jar,比如:

hadoop-streaming-0.20.2-cdh3u2.jar 
hadoop-streaming-1.2.0.jar 
hadoop-streaming.jar
k5hmc34c

k5hmc34c1#

我可以告诉你的一件事是,你没有为'-file'语句使用完整路径:
–file/mapper/location/mapper.py(在此处使用文件名的完整路径)
–mapper mapper.py(正确,仅Map文件名)
–file/reducer/location/reducer.py(在此处使用文件名的完整路径)
–reducer.py(正确,仅限reducer文件名)
确保-input和-output指向hdfs而不是本地路径
以下是我使用的代码:

hadoop jar /opt/cloudera/parcels/hadoop-streaming.jar \
-D mapred.reduce.tasks=15 -D stream.map.input.field.separator=',' -D stream.map.output.field.separator=',' \
-D mapred.textoutputformat.separator=',' \
-input /user/temp/in/ \
-output /user/temp/out \
-file  /app/qa/python/mapper.py \
-mapper mapper.py \
-file  /app/qa/python/reducer.py \
-reducer reducer.py

相关问题