如何绑定自定义hadoop-streaming.jar

57hvy0tb  于 2021-06-04  发布在  Hadoop
关注(0)|答案(2)|浏览(294)

我试着用 CombineFileInputFormat 使用yelp的mrjob工具为emr初始化。jobflow是使用hadoop流创建的,mrjob的文档指出 CombineFileInputFormat 类必须绑定到自定义的 hadoop-streaming.jar .
关于上下文,请按照这个问题。
具体来说,我的问题是:具体的类应该在哪里 CombinedInputFormat.class 被捆绑或引用在 hadoop-streaming.jar ?
我试过把这些东西捆起来 CombinedInputFormat.class 通过将其添加到目录 org/apache/hadoop/streaming 执行:

jar uvf my-hadoop-streaming.jar org/apache/hadoop/streaming

如果这样做,流式作业流将启动,并带有 -inputformat CombinedInputFormat 作业开始第一步并中断,出现错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/streaming/CombinedInputFormat (wrong name: CombinedInputFormat)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        ...

如果我只是在根路径中设置它:

jar uvf my-hadoop-streaming.jar CombinedInputFormat.class

我得到的错误是:

-inputformat : class not found : CombinedInputFormat
Streaming Job Failed!

我应该如何捆绑combinedinputformat.class,以便正确地获取它并解决问题 NoClassDefFoundError 错误?

goucqfw6

goucqfw61#

这是我发现的另一种在hadooplocal或emr中构建和运行自定义jar的简单方法http://www.applams.com/2014/05/using-custom-streaming-jar-using-custom.html

luaexgnf

luaexgnf2#

班级 CombinedInputFormat 这里解释的是 CombineFileInputFormat 并且没有用hadoop移植。因此,您需要做的是,在mapper/reducer作业类所在的包中,您必须创建一个类,并使用上一期中所述的代码。然后创建jar,它应该正常运行。
所以基本上,您需要编写自己的 CombineFileInputFormat (这是我为你做的)你可以给它取任何你想要的名字,比如说 ABCClass 而不是 CombinedInputFormat 就像我给它起的名字。

相关问题