无法使用 hadoop 流运行 Java 类文件

发布于 2024-11-26 09:47:04 字数 535 浏览 0 评论 0原文

每当我尝试使用 Java 类文件作为我的映射器和/或化简器时,我都会收到以下错误:

java.io.IOException:无法运行程序“MapperTst.class”:java.io.IOException:错误= 2,没有这样的文件或目录

我在终端上执行了以下命令:

hadoop@ubuntu:/usr/local/hadoop$ bin/hadoop jar contrib/streaming/hadoop-streaming-0.20.203.0.jar -file /home/hadoop/codes/MapperTst.class -mapper /home/hadoop/codes/MapperTst.class -file /home/hadoop/codes/ReducerTst.class -reducer /home/hadoop/codes/ReducerTst.class  -input gutenberg/* -output gutenberg-outputtstch27

Whenever I am trying to use Java class files as my mapper and/or reducer I am getting the following error:

java.io.IOException: Cannot run program "MapperTst.class": java.io.IOException: error=2, No such file or directory

I executed the following command on the terminal:

hadoop@ubuntu:/usr/local/hadoop$ bin/hadoop jar contrib/streaming/hadoop-streaming-0.20.203.0.jar -file /home/hadoop/codes/MapperTst.class -mapper /home/hadoop/codes/MapperTst.class -file /home/hadoop/codes/ReducerTst.class -reducer /home/hadoop/codes/ReducerTst.class  -input gutenberg/* -output gutenberg-outputtstch27

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情深已缘浅 2024-12-03 09:47:04

假设你的完全限定的Mapper类名(包括包)是codes.MapperTest,reducer类名是codes.ReducerTst,

将你的Map和reduce类打包到一个jar文件中,比如/home/hadoop/test.jar
如果您将命令修改为:

hadoop@ubuntu:/usr/local/hadoop$ bin/hadoop jar \
   contrib/streaming/hadoop-streaming-0.20.203.0.jar \
   -libjars /home/hadoop/test.jar \
   -mapper codes.MapperTst \
   -reducer codes.ReducerTst \
   -input gutenberg/* -output gutenberg-outputtstch27

Assuming your fully qualified Mapper class name (including the package) is codes.MapperTest and the reducer class name is codes.ReducerTst,

Package your Map and reduce classes into a jar file say /home/hadoop/test.jar
Your command should work if you modify it to :

hadoop@ubuntu:/usr/local/hadoop$ bin/hadoop jar \
   contrib/streaming/hadoop-streaming-0.20.203.0.jar \
   -libjars /home/hadoop/test.jar \
   -mapper codes.MapperTst \
   -reducer codes.ReducerTst \
   -input gutenberg/* -output gutenberg-outputtstch27
依 靠 2024-12-03 09:47:04

我也有同样的问题。解决方案是我将 java mapper/reducer/combiner 放在指定的包中。使用默认包将无法工作。它会给你你所遇到的错误。

I had the same problem. The solution was for me to put the java mapper/reducer/combiner in a specified package. With the default package it won't work. It will give you the error you had.

亢潮 2024-12-03 09:47:04

流不应该与 Java 类一起使用。它应该运行任何可以被视为 Linux 命令的东西。输入数据将被送入输入流,输出将被视为映射器输出。
如果您已经有 java 中的映射器类 - 您不需要流式传输。

Streaming is not supposed to work with Java classes. It is supposed to run anything which can be treated as a linux command. Input data will be fed into the input stream and output will be treated as an mapper output.
If you already have mapper class in java - you do not need streaming.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文