java Hortonworks Hadoop使用Virtualbox执行jar
我是hadoop的初学者。因此,我试图通过简单的例子来了解环境。因此,我创建了一个jar,它可以执行字数统计,其中包括这个Hadoop: Set up Maven project in 5 Minutes。我的问题是:我不可能执行。在我的Hortonworks沙箱里的罐子。每次出现错误时:
WARNING: Use "yarn jar" to launch YARN applications.
Not a valid JAR: /user/maria_dev/wordcount3.jar
要启动jar,我执行了以下步骤:
- 使用maven项目在eclipse中创建java类李>
- 导出可运行的jar文件李>
- 将jar加载到HDFS中(使用Ambari)李>
- 使用以下命令调用jar(使用root用户,也可以尝试使用ssh或不使用ssh):
hadoop jar /user/maria_dev/wordcount3.jar /user/maria_dev/BlackArrow.txt /user/maria_dev
/
及
hadoop jar /user/maria_dev/wordcount3.jar de.kja. wordcount3. wordcount /user/maria_dev/BlackArrow.txt /user/maria_dev/
在这两种情况下,我都从上面得到了错误
所以我有以下想法:
- 我的java类有一个错误->;我尝试了其他各种各样的例子,但都不起作用。但是,尝试将每个java文件的主类作为java应用程序运行时,会出现以下错误之一:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at de.kja.wordcount2.wordcount.main(wordcount.java:47)
或
Usage: WordCount [generic options] Generic options supported are -conf specify an application configuration file -D use value for given property -fs specify a namenode -jt specify a job tracker -files specify comma separated files to be copied to the map reduce cluster -libjars specify comma separated jar files to include in the classpath. -archives specify comma separated archives to be unarchived on the compute machines. The general command line syntax is bin/hadoop command [genericOptions] [commandOptions]
- 我读到jar文件不必上传到HDFS。那么,您是否必须将其加载到虚拟机的本地文件中?如果是:我怎么做李>
Hadoop版本:2.7.1.2.4.0.0-169
如果您需要更多信息,请询问!谢谢你的帮助:)
# 1 楼答案
在虚拟机中,打开Linux终端
苏安巴里
纱线jar/usr/hdp/current/hadoopmapreduce客户端/hadoopmapreduce示例。jar teragen 1000/tmp/genout
纱线jar/usr/hdp/current/hadoopmapreduce客户端/hadoopmapreduce示例。jar terasort/tmp/genout/tmp/sortout
纱线jar/usr/hdp/current/hadoopmapreduce客户端/hadoopmapreduce示例。jar teravalidate/tmp/sortout/tmp/valout
这是一个示例,用于确保您能够从沙箱运行作业
您需要以jar的形式运行代码