hadoop: could only be replicated to 0 nodes, instead of 1
今天安装了hadoop cluster (参考 http://hadoop.apache.org/common/docs/current/cluster_setup.html),
当执行 #bin/hadoop dfs -put input input 时,报错 ...,could only be replicated to 0 nodes, instead of 1,网上查了查,最后确定应该是iptables问题。
如果你的 conf/core-site.xml的配置是:
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://machine1:9000/</value>
</property>
</configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://machine1:9000/</value>
</property>
</configuration>
那么你应该将machine1的9000端口打开:
#iptables -I INPUT -p tcp --dport 9000 -j ACCEPT
然后可以查看
http://machine1:50070/dfshealth.jsp (你应该将500070端口也打开)
再执行,又报别的错:hdfs.DFSClient: Exception in createBlockOutputStream java.net.ConnectException: Connection refused
应该是datanode上的端口不能访问,到datanode上修改iptables:
#iptables -I INPUT -s machine1 -p tcp -j ACCEPT
OK 了!