Java Hadoop jar-系统找不到指定的路径
我正在尝试使用命令使用hadoop运行jar文件Java Hadoop jar-系统找不到指定的路径,java,hadoop,Java,Hadoop,我正在尝试使用命令使用hadoop运行jar文件 hadoop jar test.jar org.ipiran.hadoop.sample.TestMapReduce /user/data.txt /output/1.txt 4 但它返回错误 退出代码:1异常消息:系统找不到指定的路径 我试图不指定类,但得到了相同的结果。 我有data.txt文件。 我的主要java代码 public int run(String[] args) throws Exception { Configur
hadoop jar test.jar org.ipiran.hadoop.sample.TestMapReduce /user/data.txt /output/1.txt 4
但它返回错误
退出代码:1异常消息:系统找不到指定的路径
我试图不指定类,但得到了相同的结果。
我有data.txt文件。
我的主要java代码
public int run(String[] args) throws Exception {
Configuration conf = this.getConf();
conf.set("fs.defaultFS", "hdfs://localhost:9000/");
conf.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
conf.set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName());
conf.set("source", args[2]);
long numUpdated = 1;
int code = 0;
int numIterations = 1;
FileSystem hdfs = FileSystem.get(conf);
while (numUpdated > 0) {
logger.info("Iteration: " + numIterations);
String input, output;
Job job = Job.getInstance(conf, "word count");
if (numIterations == 1) {
input = args[0];
} else {
input = args[1] + "-" + (numIterations - 1);
}
output = args[1];// + "-" + numIterations;
job.setJarByClass(TestMapReduce.class);
job.setMapperClass(testmap.class);
job.setReducerClass(TestReduce.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job, new Path(input));
FileOutputFormat.setOutputPath(job, new Path(output));
code = job.waitForCompletion(true) ? 0 : 1;
Counters jobCounters = job.getCounters();
numUpdated = jobCounters.
findCounter(MoreIterations.numUpdated).getValue();
if (numIterations > 1) {
hdfs.delete(new Path(input), true);
logger.info("Updated: " + numUpdated);
}
numIterations += 1;
}
return code;
}
我用的是Windows10。有人知道这里出了什么问题吗?您使用的是Windows 10,但如果您使用的是Linux,您将如何处理它 在Linux中“/someDir/someFile表示根目录下的目录下有一个文件 您必须将数据文件的路径更改为与windows兼容的位置 顺便问一下,你的机器上安装了hadoop吗 我建议您使用linux虚拟机,您可以使用Cloudera虚拟机,因为它安装了所有内容
看到这一点,我不知道如何将其应用于hadoop代码。你能详细说明一下吗?为什么你要将文件上载到
/user
而不是实际的HDFS用户文件夹,如/user/nnnzzaaa
?谢谢你的回答。我的机器上确实安装了hadoop。这些文件位于HDFS上,它使用的是linux上的文件系统。我使用的路径与将这些文件复制到hdfs时使用的路径相同。如果我错了,那么该路径应该是什么样子?我不能使用cloudera,因为我使用的是笔记本电脑,而且它没有足够的ram。@nnnzzaa本地文件系统上没有/user文件夹,因此路径不能完全相同same@nnnzzzaaa如果该文件预期为HDFS格式,则您可以需要使用指向您的文件的hdfs路径。通常hdfs上的文件夹是/usr/something not/user请使用hadoop fs-cat/user/data.txPath确认路径是否正确。我刚刚键入了您的命令,它打印了我的文件。我想您可能需要尝试一下hdfs://yourpath 以区别于普通的本地文件系统