Hadoop format HDFs Error Java.net.UnknownHostException:localhost.localdomain:localhost.localdomain

Source: Internet
Author: User
Tags svn
Exception description

When formatting HDFS and executing the hadoop namenode -format command, an unknown host name problem occurs. The exception information is as follows:

 [shirdrn @ localhost 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 97 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:
[shirdrn @ localhost bin] # hostname
localhost.localdomain
In other words, when Hadoop formatted HDFS, the host name obtained by the hostname command was localhost.localdomain, and then it was not found when it was mapped in the / etc / hosts file. Look at my / etc / hosts :
[root @ localhost bin] # cat / etc / hosts
# Do not remove the following line, or various programs
#that require network functionality will fail.
127.0.0.1 localhost localhost
192.168.1.103 localhost localhost
In other words, localhost.localdomain cannot be mapped to an IP address at all, so an error is reported.
At this point, we take a look at the / etc / sysconfig / network file:

NETWORKING = yes
NETWORKING_IPV6 = yes
HOSTNAME = localhost.localdomain
It can be seen that by executing hostname, the value of HOSTNAME configured here is obtained.


Solution


Change the value of HOSTNAME in / etc / sysconfig / network to localhost, or specify the host name yourself, ensure that localhost is mapped to the correct IP address in the / etc / hosts file, and then restart the network service:

[root @ localhost 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 time, it is normal to execute the format HDFS command and start the HDFS cluster.

format:

[shirdrn @ localhost 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 97 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 up:
[shirdrn @ localhost 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-se
condarynamenode-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:
[shirdrn @ localhost bin] $ jps
8192 TaskTracker
7905 DataNode
7806 NameNode
8065 JobTracker
8002 SecondaryNameNode
8234 Jps
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.