[英]Hadoop jar - System cannot find the path specified
我正在嘗試使用命令使用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 {
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 VM,您可以使用Cloudera VM,因為它已安裝了所有內容
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.