Hadoop 伪分布式环境时运行wordcount程序,已经运行过一次,在次将input文件夹中的内容上传hafs文件系统时会出现重复,但是还是可以上传成功。
--------------------------------------分割线 --------------------------------------
将本地文件拷到HDFS中 http://www.linuxidc.com/Linux/2013-05/83866.htm
从HDFS下载文件到本地 http://www.linuxidc.com/Linux/2012-11/74214.htm
将本地文件上传至HDFS http://www.linuxidc.com/Linux/2012-11/74213.htm
HDFS基本文件常用命令 http://www.linuxidc.com/Linux/2013-09/89658.htm
Hadoop中HDFS和MapReduce节点基本简介 http://www.linuxidc.com/Linux/2013-09/89653.htm
《Hadoop实战》中文版+英文文字版+源码【PDF】 http://www.linuxidc.com/Linux/2012-10/71901.htm
Hadoop: The Definitive Guide【PDF版】 http://www.linuxidc.com/Linux/2012-01/51182.htm
--------------------------------------分割线 --------------------------------------
但是当再次运行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
这样再试一下就可以了
更多Hadoop相关信息见Hadoop 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=13
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-05/101825.htm
