Hadoop - 输入目录问题
Hadoop - Input directory issue
主要问题是程序启动了一个
Exception in thread "main" org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://quickstart.cloudera:8020/user/davide/wordcount/input already exists
我 运行 启动作业的命令如下:
hadoop jar wordcount.jar org.wordcount.WordCount /user/davide/wordcount/input /user/davide/wordcount/output
这似乎是正确的(输出目录不存在,就像 hadoop 假装的那样)。
在 java 文件中,路径似乎设置正确:
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
我尝试了几种解决方案,但无法弄清楚问题所在。
提前致谢。
问题在于你的参数编号:args[0]
实际上是org.wordcount.WordCount
,所以你需要使用args[1]
作为输入,args[2]
作为输出。如果您注意到,错误显示 Output directory hdfs://quickstart.cloudera:8020/user/davide/wordcount/input already exists
- 它正在尝试使用 input
文件夹作为输出。
解决这个问题:
FileInputFormat.addInputPath(job, new Path(args[1]));
FileOutputFormat.setOutputPath(job, new Path(args[2]));
主要问题是程序启动了一个
Exception in thread "main" org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://quickstart.cloudera:8020/user/davide/wordcount/input already exists
我 运行 启动作业的命令如下:
hadoop jar wordcount.jar org.wordcount.WordCount /user/davide/wordcount/input /user/davide/wordcount/output
这似乎是正确的(输出目录不存在,就像 hadoop 假装的那样)。
在 java 文件中,路径似乎设置正确:
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
我尝试了几种解决方案,但无法弄清楚问题所在。
提前致谢。
问题在于你的参数编号:args[0]
实际上是org.wordcount.WordCount
,所以你需要使用args[1]
作为输入,args[2]
作为输出。如果您注意到,错误显示 Output directory hdfs://quickstart.cloudera:8020/user/davide/wordcount/input already exists
- 它正在尝试使用 input
文件夹作为输出。
解决这个问题:
FileInputFormat.addInputPath(job, new Path(args[1]));
FileOutputFormat.setOutputPath(job, new Path(args[2]));