Hadoop hdfs文件系统文件已存在 解决办法

2022-07-01 14:14:45 浏览数 (1)

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

这样再试一下就可以了

0 人点赞