Exception description
In the case of an unknown hostname when you format the Hadoop namenode-format command on HDFS, the exception information is as follows:
[Plain]View PlainCopy
- [Email protected] bin]$ Hadoop Namenode-format
- 11/06/22 07:33:31 INFO Namenode. Namenode:startup_msg:
- /************************************************************
- Startup_msg:starting NameNode
- Startup_msg:host = Java.net.UnknownHostException:localhost.localdomain:localhost.localdomain
- Startup_msg:args = [-format]
- Startup_msg:version = 0.20.0
- Startup_msg:build = Https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20-r 763504; Compiled by ' Ndaley ' on Thu Apr 9 05:18:40 UTC 2009
- ************************************************************/
- Re-format filesystem In/tmp/hadoop/hadoop-shirdrn/dfs/name? (Y or N) Y
- 11/06/22 07:33:36 INFO Namenode. Fsnamesystem:fsowner=shirdrn,shirdrn
- 11/06/22 07:33:36 INFO Namenode. Fsnamesystem:supergroup=supergroup
- 11/06/22 07:33:36 INFO Namenode. Fsnamesystem:ispermissionenabled=true
- 11/06/22 07:33:36 INFO Metrics. Metricsutil:unable to obtain HostName
- Java.net.UnknownHostException:localhost.localdomain:localhost.localdomain
- At Java.net.InetAddress.getLocalHost (inetaddress.java:1353)
- At Org.apache.hadoop.metrics.MetricsUtil.getHostName (metricsutil.java:91)
- At Org.apache.hadoop.metrics.MetricsUtil.createRecord (metricsutil.java:80)
- At Org.apache.hadoop.hdfs.server.namenode.FSDirectory.initialize (fsdirectory.java:73)
- At Org.apache.hadoop.hdfs.server.namenode.fsdirectory.<init> (fsdirectory.java:68)
- At Org.apache.hadoop.hdfs.server.namenode.fsnamesystem.<init> (fsnamesystem.java:370)
- At Org.apache.hadoop.hdfs.server.namenode.NameNode.format (namenode.java:853)
- At Org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode (namenode.java:947)
- At Org.apache.hadoop.hdfs.server.namenode.NameNode.main (namenode.java:964)
- 11/06/22 07:33:36 INFO Common. Storage:image file of size saved in 0 seconds.
- 11/06/22 07:33:36 INFO Common. Storage:storage Directory/tmp/hadoop/hadoop-shirdrn/dfs/name has been successfully formatted.
- 11/06/22 07:33:36 INFO Namenode. Namenode:shutdown_msg:
- /************************************************************
- Shutdown_msg:shutting down NameNode at Java.net.UnknownHostException:localhost.localdomain:localhost.localdomain
- ************************************************************/
We can see by executing the hostname command:
[Plain]View PlainCopy
- [Email protected] bin]# hostname
- Localhost.localdomain
That is, Hadoop in the format of HDFs, the host name obtained through the hostname command is Localhost.localdomain, and then in the/etc/hosts file mapping, not found, look at my/etc/ Hosts content:
[Plain]View PlainCopy
- [Email protected] bin]# cat/etc/hosts
- # don't remove the following line, or various programs
- # that require network functionality would fail.
- 127.0.0.1 localhost localhost
- 192.168.1.103 localhost localhost
Also said that through the localhost.localdomain can not be mapped to an IP address, so the error.
At this point, we look at the/etc/sysconfig/network file:
[Plain]View PlainCopy
- Networking=yes
- Networking_ipv6=yes
- Hostname=localhost.localdomain
Visible, execute hostname Gets the value of the hostname configured here.
Workaround
Modify the value of hostname in/etc/sysconfig/network to localhost, or the host name that you specify, to ensure that localhost maps to the correct IP address in the/etc/hosts file, and then restart the Network service:
[Plain]View PlainCopy
- [Email protected] bin]#/etc/rc.d/init.d/network restart
- Shutting down interface eth0: [OK]
- Shutting down loopback interface: [OK]
- Bringing up loopback interface: [OK]
- Bringing Up interface eth0:
- Determining IP information for eth0 ... done.
- [OK]
At this point, the format HDFs command is executed, and the HDFs cluster is started properly.
Formatting:
[Plain]View PlainCopy
- [Email protected] bin]$ Hadoop Namenode-format
- 11/06/22 08:02:37 INFO Namenode. Namenode:startup_msg:
- /************************************************************
- Startup_msg:starting NameNode
- Startup_msg:host = localhost/127.0.0.1
- Startup_msg:args = [-format]
- Startup_msg:version = 0.20.0
- Startup_msg:build = Https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20-r 763504; Compiled by ' Ndaley ' on Thu Apr 9 05:18:40 UTC 2009
- ************************************************************/
- 11/06/22 08:02:37 INFO Namenode. Fsnamesystem:fsowner=shirdrn,shirdrn
- 11/06/22 08:02:37 INFO Namenode. Fsnamesystem:supergroup=supergroup
- 11/06/22 08:02:37 INFO Namenode. Fsnamesystem:ispermissionenabled=true
- 11/06/22 08:02:37 INFO Common. Storage:image file of size saved in 0 seconds.
- 11/06/22 08:02:37 INFO Common. Storage:storage Directory/tmp/hadoop/hadoop-shirdrn/dfs/name has been successfully formatted.
- 11/06/22 08:02:37 INFO Namenode. Namenode:shutdown_msg:
- /************************************************************
- Shutdown_msg:shutting down NameNode at localhost/127.0.0.1
- ************************************************************/
Start:
[Plain]View PlainCopy
- [Email protected] bin]$ start-all.sh
- Starting Namenode, logging to/home/shirdrn/eclipse/eclipse-3.5.2/hadoop/hadoop-0.20.0/logs/ Hadoop-shirdrn-namenode-localhost.out
- Localhost:starting Datanode, logging to/home/shirdrn/eclipse/eclipse-3.5.2/hadoop/hadoop-0.20.0/logs/ Hadoop-shirdrn-datanode-localhost.out
- Localhost:starting Secondarynamenode, logging to/home/shirdrn/eclipse/eclipse-3.5.2/hadoop/hadoop-0.20.0/logs/ Hadoop-shirdrn-secondarynamenode-localhost.out
- Starting Jobtracker, logging to/home/shirdrn/eclipse/eclipse-3.5.2/hadoop/hadoop-0.20.0/logs/ Hadoop-shirdrn-jobtracker-localhost.out
- Localhost:starting Tasktracker, logging to/home/shirdrn/eclipse/eclipse-3.5.2/hadoop/hadoop-0.20.0/logs/ Hadoop-shirdrn-tasktracker-localhost.out
View:
[Plain]View PlainCopy
- [Email protected] bin]$ JPS
- 8192 Tasktracker
- 7905 DataNode
- 7806 NameNode
- 8065 Jobtracker
- 8002 Secondarynamenode
- 8234 Jps
- From 6562292
Hadoop formatted HDFS error Java.net.UnknownHostException:localhost.localdomain:localhost.localdomain