无法使用 hadoop 流运行 Java 类文件
每当我尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设你的完全限定的Mapper类名(包括包)是codes.MapperTest,reducer类名是codes.ReducerTst,
将你的Map和reduce类打包到一个jar文件中,比如/home/hadoop/test.jar
如果您将命令修改为:
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 :
我也有同样的问题。解决方案是我将 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.
流不应该与 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.