windows上用cygwin运行Hadoop

Linux上安装过程参考http://blog.csdn.net/sulliy/article/details/7014169


Windows上安装还是主要SSH和Java JDK。详细的参考在 Windows上安装Hadoop教程


主要问题在于开启HDFS后,本地文件和HDFS中的文件使用上,可能会遇到如下错误:

java.io.FileNotFoundException: File C:/tmp/hadoop-SYSTEM/mapred/local/taskTracker/jobcache/job_201007171612_0006/attempt_201007171612_0006_m_000001_0/work/tmp does not exist.
at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:361)
at org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:245)
at org.apache.hadoop.mapred.TaskRunner.setupWorkDir(TaskRunner.java:519)
at org.apache.hadoop.mapred.Child.main(Child.java:155)

map过程中需要一些临时文件来存放map的结果。错误的原因在于找不到该临时文件。将mapred-site.xml配置文件中的配置mapred.child.tmp改为一个绝对路径:

<property>
  <name>mapred.child.tmp</name>
  <value>E:\Apache\Hadoop\Run\tmp</value>
  <description> To set the value of tmp directory for map and reduce tasks.
  If the value is an absolute path, it is directly assigned. Otherwise, it is
  prepended with task's working directory. The java tasks are executed with
  option -Djava.io.tmpdir='the absolute path of the tmp dir'. Pipes and
  streaming are set with environment variable,
   TMPDIR='the absolute path of the tmp dir'
  </description>
</property>


另一种错误是reduce结果存放的文件已经存在:

org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://loc
alhost:8888/user/Administrator/output already exists
        at org.apache.hadoop.mapred.FileOutputFormat.checkOutputSpecs(FileOutput
Format.java:111)
        at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:7
72)
        at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:730)
        at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1249)
        at org.apache.hadoop.examples.Grep.run(Grep.java:84)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
        at org.apache.hadoop.examples.Grep.main(Grep.java:93)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(Progra
mDriver.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:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:156)


Hadoop的文件设计为大块的流式文件,一般采用追加的方式,文件不会被更新修改。如果该文件已经存在,用户应该删除它。


Cygwin把Window上的文件路径映射为类似:/cygdrive/e/Apache/hadoop/run/hadoop-0.20.2/bin,表示E:Apache/hadoop/run/hadoop-0.20.2/bin。三层的文件路径变换把人搅晕了,还是推荐初学者在Linus本地文件模式下使用。


你可能感兴趣的:(java,apache,hadoop,windows,Path,output)