【发布时间】:2012-01-31 18:05:48
【问题描述】:
我已经建立了一个小型 Hadoop 集群进行测试。 NameNode(1 台机器)、SecondaryNameNode(1)和所有 DataNode(3)的设置都进行得相当顺利。这些机器被命名为“master”、“secondary”和“data01”、“data02”和“data03”。所有 DNS 均已正确设置,无密码 SSH 从主/从配置到所有机器并返回。
我使用bin/hadoop namenode -format 格式化集群,然后使用bin/start-all.sh 启动所有服务。使用jps 检查所有节点上的所有进程是否已启动并运行。我的基本配置文件如下所示:
<!-- conf/core-site.xml -->
<configuration>
<property>
<name>fs.default.name</name>
<!--
on the master it's localhost
on the others it's the master's DNS
(ping works from everywhere)
-->
<value>hdfs://localhost:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<!-- I picked /hdfs for the root FS -->
<value>/hdfs/tmp</value>
</property>
</configuration>
<!-- conf/hdfs-site.xml -->
<configuration>
<property>
<name>dfs.name.dir</name>
<value>/hdfs/name</value>
</property>
<property>
<name>dfs.data.dir</name>
<value>/hdfs/data</value>
</property>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
</configuration>
# conf/masters
secondary
# conf/slaves
data01
data02
data03
我现在只是想让 HDFS 正常运行。
我创建了一个测试目录hadoop fs -mkdir testing,然后尝试使用hadoop fs -copyFromLocal /tmp/*.txt testing 将一些文件复制到其中。这是 hadoop 崩溃的时候,或多或少地给了我这个:
WARN hdfs.DFSClient: DataStreamer Exception: org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /user/hd/testing/wordcount1.txt could only be replicated to 0 nodes, instead of 1
at ... (such and such)
WARN hdfs.DFSClient: Error Recovery for block null bad datanode[0] nodes == null
at ...
WARN hdfs.DFSClient: Could not get block locations. Source file "/user/hd/testing/wordcount1.txt" - Aborting...
at ...
ERROR hdfs.DFSClient: Exception closing file /user/hd/testing/wordcount1.txt: org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /user/hd/testing/wordcount1.txt could only be replicated to 0 nodes, instead of 1
at ...
等等。当我尝试从 DataNode 机器上运行 hadoop fs -lsr . 时,也会出现类似的问题,但结果如下:
12/01/02 10:02:11 INFO ipc.Client: Retrying connt to server master/192.162.10.10:9000. Already tried 0 time(s).
12/01/02 10:02:12 INFO ipc.Client: Retrying connt to server master/192.162.10.10:9000. Already tried 1 time(s).
12/01/02 10:02:13 INFO ipc.Client: Retrying connt to server master/192.162.10.10:9000. Already tried 2 time(s).
...
我说这很相似,因为我怀疑这是端口可用性问题。运行telnet master 9000 表明端口已关闭。我在某处读到这可能是 IPv6 冲突问题,因此在 conf/hadoop-env.sh 中定义了以下内容:
export HADOOP_OPTS=-Djava.net.preferIPv4Stack=true
但这并没有成功。在 master 上运行 netstat 会显示如下内容:
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:9000 localhost:56387 ESTABLISHED
tcp 0 0 localhost:56386 localhost:9000 TIME_WAIT
tcp 0 0 localhost:56387 localhost:9000 ESTABLISHED
tcp 0 0 localhost:56384 localhost:9000 TIME_WAIT
tcp 0 0 localhost:56385 localhost:9000 TIME_WAIT
tcp 0 0 localhost:56383 localhost:9000 TIME_WAIT
此时我很确定问题出在端口 (9000) 上,但我不确定在配置方面我错过了什么。有任何想法吗?谢谢。
更新
我发现将 DNS 名称硬编码为 /etc/hosts 不仅有助于解决此问题,而且还加快了连接速度。缺点是您必须在集群中的所有机器上执行此操作,并且在添加新节点时再次执行此操作。或者你可以只设置一个 DNS 服务器,我没有。
这是我集群中的一个节点的示例(节点名为hadoop01、hadoop02 等,主节点和辅助节点分别为 01 和 02)。大部分由操作系统生成的节点:
# this is a sample for a machine with dns hadoop01
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastrprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allroutes
# --- Start list of nodes
192.168.10.101 hadoop01
192.168.10.102 hadoop02
192.168.10.103 hadoop03
192.168.10.104 hadoop04
192.168.10.105 hadoop05
192.168.10.106 hadoop06
192.168.10.107 hadoop07
192.168.10.108 hadoop08
192.168.10.109 hadoop09
192.168.10.110 hadoop10
# ... and so on
# --- End list of nodes
# Auto-generated hostname. Please do not remove this comment.
127.0.0.1 hadoop01 localhost localhost.localdomain
希望这会有所帮助。
【问题讨论】:
标签: networking hadoop port hdfs