hadoop namenode配置以及问题处理
第一步:修改core-site.xml,配置如下内容:
<?xml version="1.0"?><?xml-stylesheet type="text/xsl"href="configuration.xsl"?>
<!-- Put site-specific property overrides in thisfile. -->
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
<final>true</final>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
第二步:修改hdfs-site.xml文件,配置如下内容:
<?xml version="1.0"?><?xml-stylesheet type="text/xsl"href="configuration.xsl"?>
<!-- Put site-specific property overrides in thisfile. -->
<configuration>
<property>
<name>dfs.name.dir</name>
<value>/cygdrive/d/hadoop/working/name</value>
<final>true</final>
</property><property>
<name>dfs.data.dir</name>
<value>/cygdrive/d/hadoop/working/data</value>
<final>true</final>
</property><property>
<name>fs.checkpoint.dir</name>
<value>/cygdrive/d/hadoop/working/checkpoint</value>
<final>true</final>
</property></configuration>
第三步:修改mapred-site.xml配置如下内容:
<?xml version="1.0"?><?xml-stylesheet type="text/xsl"href="configuration.xsl"?>
<!-- Put site-specific property overrides in thisfile. -->
<configuration><property>
<name>mapred.job.tracker</name>
<value>hdfs://localhost:9001</value>
<final>true</final>
</property><property>
<name>mapred.local.dir</name>
<value>/cygdrive/d/hadoop/working/dir1,/cygdrive/d/hadoop/working/dir2</value>
<final>true</final>
</property><property>
<name>mapred.system.dir</name>
<value>/cygdrive/d/hadoop/working/system</value>
<final>true</final>
</property></configuration>
第4步,进入cygwin客户端,执行
$ cd /cygdrive/d/hadoop 【其中/d/hadoop为hadoop安装目录,即d:\hadoop,linux表示路径和windows不同】
$ bin/hadoop namenode –format 【格式化namenode】
第5步,修改工作目录权限
$ bin/hadoop dfs chmod 777 /cygdrive/d/hadoop/working【/cygdrive/d/hadoop/working 为工作目录,默认是tmp】
第6步,启动hadoop
$ bin/start-all.sh
$ps–ef
通过ps查看进程,能看到5个java进程,即成功。常见问题
(1)
执行 $ bin/hadoop start-all.sh之后,无法启动,在logs的namenode日志发现如下内容:
2011-08-03 08:43:08,068 ERRORorg.apache.hadoop.hdfs.server.namenode.NameNode:java.lang.NullPointerException
atorg.apache.hadoop.net.NetUtils.createSocketAddr(NetUtils.java:136)
atorg.apache.hadoop.hdfs.server.namenode.NameNode.getAddress(NameNode.java:176)
atorg.apache.hadoop.hdfs.server.namenode.NameNode.getAddress(NameNode.java:206)
atorg.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:240)
atorg.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:434)
atorg.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1153)
atorg.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1162)解决方法:此时是没有配置conf/mapred-site.xml的缘故. 配置core-site.xml文件
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
<final>true</final>
</property>
配置mapred-site.xml文件:
<property>
<name>mapred.job.tracker</name>
<value>hdfs://localhost:9001</value>
<final>true</final>
</property>(2)执行 hadoop fs -ls 显示结果:ls: Cannot access .: No such file or directory.
这是这个目录为空所致。执行
hadoop fs -ls /
可以看到有一条结果。执行hadoop fs -mkdir hello其中hello为文件夹名字,再执行ls命令,即可看到结果。
(3) TaskTracker无法启动,在logs中查看tasktracker日志,出现如下错误:
2011-08-03 08:46:45,750 ERRORorg.apache.hadoop.mapred.TaskTracker: Can not start task trackerbecause java.io.IOException: Failed to set permissions of path:/cygdrive/d/hadoop/working/dir1/ttprivate to 0700
atorg.apache.hadoop.fs.RawLocalFileSystem.checkReturnValue(RawLocalFileSystem.java:525)
atorg.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:499)
atorg.apache.hadoop.fs.RawLocalFileSystem.mkdirs(RawLocalFileSystem.java:318)
atorg.apache.hadoop.fs.FilterFileSystem.mkdirs(FilterFileSystem.java:183)
atorg.apache.hadoop.mapred.TaskTracker.initialize(TaskTracker.java:635)
atorg.apache.hadoop.mapred.TaskTracker.<init>(TaskTracker.java:1328)
atorg.apache.hadoop.mapred.TaskTracker.main(TaskTracker.java:3430)解决方式:1.确认hadoop的版本,在0.20.203版本上有这个bug,切换会0.20.2版本;2.执行第5步,授权
通过浏览器访问 http://localhost:50070/ ,能正常访问,表示namenode配置成功