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
  • 1.hdfs的output目录已经存在。

检查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上运行是没问题的,在集群上运行的时候指定了全类名,把它当做输入了。此时输出采用输入路径作为输入了。固显示输出路径已存在。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM