SHUTDOWN_MSG: Shutting down NameNode at java.net.UnknownHostException

启动hadoop namenode -format命令时报如下错误:

java.net.UnknownHostException: #centos-linux.shared
master: #centos-linux.shared
master
	at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
	at org.apache.hadoop.net.DNS.resolveLocalHostIPAddress(DNS.java:287)
	at org.apache.hadoop.net.DNS.<clinit>(DNS.java:58)
	at org.apache.hadoop.hdfs.server.namenode.NNStorage.newBlockPoolID(NNStorage.java:945)
	at org.apache.hadoop.hdfs.server.namenode.NNStorage.newNamespaceInfo(NNStorage.java:573)
	at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:144)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:899)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1310)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1424)
Caused by: java.net.UnknownHostException: #centos-linux.shared
master
	at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
	at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
	at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
	at java.net.InetAddress.getLocalHost(InetAddress.java:1469)
	... 8 more
16/06/23 17:29:40 INFO namenode.FSImage: Allocated new BlockPoolId: BP-127474426-127.0.0.1-1466674179873
16/06/23 17:29:40 INFO common.Storage: Storage directory /home/qian/hadoop/tmp/dfs/name has been successfully formatted.
16/06/23 17:29:40 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
16/06/23 17:29:40 INFO util.ExitUtil: Exiting with status 0
16/06/23 17:29:40 INFO namenode.NameNode: SHUTDOWN_MSG: 
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at java.net.UnknownHostException: #centos-linux.shared
master: #centos-linux.shared
master
************************************************************/
[root@centos-linux sbin]# 

原因很简单,我以为/etc/hostname里面可以用#注释,于是我把之前的代码centos-linux.shared注释掉

#centos-linux.shared

 结果证明是不行的,格式化hadoop时一直报错,找不到主机名#centos-linux.shared

最后干脆把#centos-linux.shared这行删掉,结果就成功了。所以有时候一些没用的代码还是删掉为好。

 

其中这些文章给我提供了很大的帮助:

 

SHUTDOWN_MSG: Shutting down NameNode at java.net.UnknownHostException: xxx

Centos 7 学习之静态IP设置

一步步教你Hadoop多节点集群安装配置

Hadoop安装教程

 http://www.powerxing.com/install-hadoop/

你可能感兴趣的:(linux,hadoop,常见错误)