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