hadoop jar命令指向本地文件系统 [英] hadoop jar command points to local filesystem
问题描述
我有一个有效的jar,可以在运行相同版本hadoop的另一个系统上完美运行,即具有相同设置的hadoop-1.2.1。
把这个jar文件放到hdfs文件系统中,并创建输入,输出目录。
但是当我使用命令'hadoop jar HelloWorld.jar classname(main method)input output '它会抛出'jar无效'错误。在长时间搜索可能的解决方案后,我发现该命令在本地文件系统中搜索jar,而不是在hdfs中搜索。
即使我尝试添加方案的命令如下:
hadoop jar hdfs://HelloWorld.jar classname(main method)input output
有什么可行的解决方案? / p>
PS:当我的PWD是/home/user/hadoop-1.2.1时,我可以使用'hadoop jar'运行hadoop-examples-1.2.1.jar这是在我的本地文件系统中
hadoop jar
您可以在本地访问 1 。只是为了好奇 - 这里是在 hadoop jar
命令中查找jar的相关源代码。
public static void main(String [] args)throws Throwable {
String usage =RunJar jarFile [mainClass] args ...;
if(args.length< 1){
System.err.println(usage);
System.exit(-1);
}
int firstArg = 0;
String fileName = args [firstArg ++];
档案档案=新档案(档案名称);
if(!file.exists()||!file.isFile()){
System.err.println(Not a valid JAR:+ file.getCanonicalPath());
System.exit(-1);
}
...
}
1 对于我所遇到的每个Hadoop版本都是如此。您的结果可能会有所不同。
I have a valid jar which is running perfectly on another system running the same version of hadoop i.e hadoop-1.2.1 with the same settings.
I am able to put the jar file in the hdfs filesystem and create input,output directories.
But when I use the command 'hadoop jar HelloWorld.jar classname(main method) input output' it throws 'Invalid jar' error. After searching for the possible solutions for a long time I found out that the command is searching for the jar in local filesystem instead of searching in the hdfs.
Even I tried adding scheme to the command as: hadoop jar hdfs://HelloWorld.jar classname(main method) input output
What are the possible solutions to this?
P.S: I am able to run the hadoop-examples-1.2.1.jar using 'hadoop jar' when my PWD is /home/user/hadoop-1.2.1 which is in my local filesystem
hadoop jar
only runs jar files that you can access locally1. Just for the sake of curiosity - here is the relevant source that looks for the jar in the hadoop jar
command.
public static void main(String[] args) throws Throwable {
String usage = "RunJar jarFile [mainClass] args...";
if (args.length < 1) {
System.err.println(usage);
System.exit(-1);
}
int firstArg = 0;
String fileName = args[firstArg++];
File file = new File(fileName);
if (!file.exists() || !file.isFile()) {
System.err.println("Not a valid JAR: " + file.getCanonicalPath());
System.exit(-1);
}
...
}
1 This is true for every Hadoop version I've come accross. Your results may vary.
这篇关于hadoop jar命令指向本地文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!