1. 程式人生 > >將jar包上傳到Hadoop伺服器並執行jar包的方法--引數不對應導致報錯output directory already exists

將jar包上傳到Hadoop伺服器並執行jar包的方法--引數不對應導致報錯output directory already exists

 ERROR security.UserGroupInformation: PriviledgedActionException as:root cause:org.apache.hadoop.mapred.FileAlreadyExistsException:Output directory hdfs://。。。。/user/root/input already exists 是由於引數不對應引起的,即,講input資料夾對應到output引數上了。正確的執行jar包的方法為: 1.通過crt把自己的打包好的工程上傳到hadoop伺服器上。 2.首先確認中間輸出結果路徑是不存在的,執行刪除方法:   bin/hadoop fs -rmr output 3.建立輸入路徑input,並上傳輸入檔案至該資料夾。 4.執行指令執行jar包wordcount.jar:   bin/hadoop jar wordcount.jar input output 這裡要注意引數個數,如果在打包時就已經指定了執行main方法的類,比如WordCount類,那麼在執行上述指令時就不要在指定類了,如果寫: bin/hadoop jar wordcount.jar WordCount input output 那麼就需要在工程裡面修改對應引數: FileInputFormat.setInputPaths(conf,new Path(args[0]));0改為1 FileOutputFormat.setOutputPath(conf,new Path(args[1]));1改為2 最好的方法就是不再加上WordCount這個引數。