hadoop hdfs文件系統文件以存在 解決辦法

hadoop 僞分佈式環境時運行wordcount程序,已經運行過一次,在次將input文件夾中的內容上傳hafs文件系統時會出現重複,但是還是可以上傳成功。

但是當再次運行wordcount程序時就會報以下的錯誤

hadoop@salve:~/programfile/hadoop$ bin/hadoop jar hadoop-examples-*.jar wordcount /input /output
14/05/16 08:50:00 INFO mapred.JobClient: Cleaning up the staging area hdfs://localhost:9000/tmp/hadoop-hadoop/mapred/staging/hadoop/.staging/job_201405160835_0004
14/05/16 08:50:00 ERROR security.UserGroupInformation: PriviledgedActionException as:hadoop cause:org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory /output already exists
org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory /output already exists
    at org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.checkOutputSpecs(FileOutputFormat.java:137)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:949)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:912)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1136)
    at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:912)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:500)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:530)
    at org.apache.hadoop.examples.WordCount.main(WordCount.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:68)
    at org.apache.hadoop.util.ProgramDriver.driver(ProgramDriver.java:139)
    at org.apache.hadoop.examples.ExampleDriver.main(ExampleDriver.java:64)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
                                                                                 
at org.apache.hadoop.util.RunJar.main(RunJar.java:156)


從這行錯誤提示中

hadoop cause:org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory /output already exists

org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory /output already exists

可以看到導致錯誤的原因時hdfs文件系統中的output文件夾已經存在了,所以必須要刪除。(因爲outout文件夾是由hadoop自動生成的,所以會報錯)


我使用的hadoop是 hadoop-1.1.0

查看hdfs文件系統的命令爲

hadoop@salve:~/programfile/hadoop$ bin/hadoop fs -ls /


刪除output文件夾和tmp文件夾

hadoop@salve:~/programfile/hadoop$ bin/hadoop fs -rmr /output
hadoop@salve:~/programfile/hadoop$ bin/hadoop fs -rmr /tmp

這樣再試一下就可以了


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章