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

posted @   Sofiacodes  阅读(3397)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示