Hadoop运行错误:输出目录已存在 - Output directory hdfs://master:9000/output already exists
Hadoop运行错误 – Output directory hdfs://master:9000/output already exists
在集群上测试:
hadoop jar /opt/software/wc.jar com.atguigu.mapreduce.WordCountDriver /wc.input /wc.output
自编译的wordcount出现的错误:
Exception in thread "main" org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://hadoop102:9000/wc.input already exists
检查hdfs文件系统上并没有output目录 :有则删除即可
-
2.检查java代码路径是否错误
//5.指定job原始文件输入目录
FileInputFormat.setInputPaths(job, new Path(args[0])); //args:当前所运行的参数(取第一个参数)
//指定job输出结果所在的目录
FileOutputFormat.setOutputPath(job, new Path(args[1])); //args:当前所运行的参数(取第二个参数)问题出在您的参数编号上:
args[0]
实际上是com.atguigu.mapreduce.WordCountDriver(主类名),因此您需要使用
args[1]作为输入,使用
args[2]作为输出。
错误显示为
Output directory hdfs://hadoop102:9000/wc.input already exists:它正在尝试使用
input文件夹作为输出。更改一下运行参数序号即可FileInputFormat.addInputPath(job, new Path(args[1]));
FileOutputFormat.setOutputPath(job, new Path(args[2]));
总结:在idea上运行是没问题的,在集群上运行的时候指定了全类名,把它当做输入了。此时输出采用输入路径作为输入了。固显示输出路径已存在。