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上运行是没问题的,在集群上运行的时候指定了全类名,把它当做输入了。此时输出采用输入路径作为输入了。固显示输出路径已存在。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?