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上運行是沒問題的,在集群上運行的時候指定了全類名,把它當做輸入了。此時輸出采用輸入路徑作為輸入了。固顯示輸出路徑已存在。