最近因工作需要要打个Hadoop集群,过程中碰到一些问题,也费了些精力去解决,现将这些问题记录一下。
1. root与CDH3u4
CDH默认是不支持root用户的, 如果仍想用 root 来搭建,可以从Apache Hadoop里下载你要的版本来搭建,但是仍会出现
Could not create the Java Virtual machine. unrecognized option: -jvm
的错误,这时要去编辑 bin/hadoop 脚本,找到里面的判断 if [[$EUID -eq 0]]; then
HADOOP_OPTS="$HADOOP_OPTS -jvm server $HADOOP_DATANODE_OPTS"
else
HADOOP_OPTS="$HADOOP_OPTS -server $HADOOP_DATANODE_OPTS"
fi
因为当前的$EUID 是root, 为零,所以会执行 then 里的 语句,要解决这个问题只要把 then 里的 -jvm server 改为 -server(及和 else 的语句相同即可)。
2. 注意每次搭建后,都一定要 bin/hadoop namenode -format, 不然会连不通的, Already try xx times(), blahblahblah .
3. 运行 bin/hadoop dfsadmin -report 后,结果如下:
Configured Capacity: 0 (0 KB)
Present Capacity: 0 (0 KB)
DFS Remaining: 0 (0 KB)
DFS Used: 0 (0 KB)
DFS Used%: �%
Under replicated blocks: 0
Blocks with corrupt replicas: 0
Missing blocks: 0
-------------------------------------------------
Datanodes available: 0 (0 total, 0 dead)
我遇到的这个问题,多半是因为重新运行了 bin/hadoop namenode -format 命令, 因为上一次format的数据还没清空。所以解决办法是把hdfs-site.xml中配置的 dfs.name.dir 和 dfs.data.dir(如果有重要数据,这个就不要删了) 全删了,再重新 format 就行了。
4. 使用 hadoop fs -put file1.txt in 上传文件到HDFS in 目录下时, 出现
ERROR: hdf.DFSclient: Exception closing file /user/root/in : org.apache.ipc.
RemoteException: java.io.IOException: File /usr/root/in could only be replicate to 0 nodes, instead of 1.
这应该是HDFS没正常启动。用 hadoop namenode format 重新格式化一次就能解决问题了。http://blog.csdn.net/wh62592855/article/details/5744158
如果还不行,则可能是开启了防火墙和safemode on的问题。 参 http://hi.baidu.com/xiaomi/item/49d16a90720d16f629164727 http://www.oschina.net/question/188742_41144