博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Hadoop格式化HDFS报错java.net.UnknownHostException: localhost.localdomain: localhost.localdomain
阅读量:6440 次
发布时间:2019-06-23

本文共 5380 字,大约阅读时间需要 17 分钟。

异常描述:

在对HDFS格式化,执行hadoop namenode -format命令时,出现未知的主机名的问题,异常信息如下所示:

[shirdrn@localhost bin]$ hadoop namenode -format11/06/22 07:33:31 INFO namenode.NameNode: STARTUP_MSG: /************************************************************STARTUP_MSG: Starting NameNodeSTARTUP_MSG:   host = java.net.UnknownHostException: localhost.localdomain: localhost.localdomainSTARTUP_MSG:   args = [-format]STARTUP_MSG:   version = 0.20.0STARTUP_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) Y11/06/22 07:33:36 INFO namenode.FSNamesystem: fsOwner=shirdrn,shirdrn11/06/22 07:33:36 INFO namenode.FSNamesystem: supergroup=supergroup11/06/22 07:33:36 INFO namenode.FSNamesystem: isPermissionEnabled=true11/06/22 07:33:36 INFO metrics.MetricsUtil: Unable to obtain hostNamejava.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.
(FSDirectory.java:68) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.
(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************************************************************/

我们通过执行hostname命令可以看到:

[shirdrn@localhost bin]# hostnamelocalhost.localdomain

也就是说,Hadoop在格式化HDFS的时候,通过hostname命令获取到的主机名是localhost.localdomain,然后在/etc/hosts文件中进行映射的时候,没有找到,看下我的/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       localhost192.168.1.103           localhost       localhost

也就说,通过localhost.localdomain根本无法映射到一个IP地址,所以报错了。

此时,我们查看一下/etc/sysconfig/network文件:

NETWORKING=yesNETWORKING_IPV6=yesHOSTNAME=localhost.localdomain

可见,执行hostname获取到这里配置的HOSTNAME的值。

解决方法

修改/etc/sysconfig/network中HOSTNAME的值为localhost,或者自己指定的主机名,保证localhost在/etc/hosts文件中映射为正确的IP地址,然后重新启动网络服务:

[root@localhost bin]# /etc/rc.d/init.d/network restartShutting 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  ]

这时,再执行格式化HDFS命令,以及启动HDFS集群就正常了。

格式化:

[shirdrn@localhost bin]$ hadoop namenode -format11/06/22 08:02:37 INFO namenode.NameNode: STARTUP_MSG: /************************************************************STARTUP_MSG: Starting NameNodeSTARTUP_MSG:   host = localhost/127.0.0.1STARTUP_MSG:   args = [-format]STARTUP_MSG:   version = 0.20.0STARTUP_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,shirdrn11/06/22 08:02:37 INFO namenode.FSNamesystem: supergroup=supergroup11/06/22 08:02:37 INFO namenode.FSNamesystem: isPermissionEnabled=true11/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************************************************************/

启动:

[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.outlocalhost: starting datanode, logging to /home/shirdrn/eclipse/eclipse-3.5.2/hadoop/hadoop-0.20.0/logs/hadoop-shirdrn-datanode-localhost.outlocalhost: starting secondarynamenode, logging to /home/shirdrn/eclipse/eclipse-3.5.2/hadoop/hadoop-0.20.0/logs/hadoop-shirdrn-secondarynamenode-localhost.outstarting jobtracker, logging to /home/shirdrn/eclipse/eclipse-3.5.2/hadoop/hadoop-0.20.0/logs/hadoop-shirdrn-jobtracker-localhost.outlocalhost: starting tasktracker, logging to /home/shirdrn/eclipse/eclipse-3.5.2/hadoop/hadoop-0.20.0/logs/hadoop-shirdrn-tasktracker-localhost.out

查看:

[shirdrn@localhost bin]$ jps8192 TaskTracker7905 DataNode7806 NameNode8065 JobTracker8002 SecondaryNameNode8234 Jps

 

转载地址:http://bqdwo.baihongyu.com/

你可能感兴趣的文章
用友网络董事长王文京为何出现在乌镇大会中?
查看>>
大学团队打造手语翻译机器人,完整安装下来需要149个小时
查看>>
Wireshark抓包分析/TCP/Http/Https及代理IP的识别
查看>>
不同包下,相同数据结构的两个类进行转换
查看>>
软件安装(linux)
查看>>
TeamPlain for VSTS - Web Access for Team System-TFS 跨平台的客户端
查看>>
面对前车之鉴的AR,现在的VR要做些什么?
查看>>
vscode 换行符\n 变成\r\n
查看>>
一个绘制虚线的非常规函数(常规方法,打印机上绘制不出虚线)
查看>>
获得本机的IP,掩码和网关
查看>>
大数据之 ZooKeeper原理及其在Hadoop和HBase中的应用
查看>>
Delphi中将XML文件数据装入DataSet
查看>>
你刚才在淘宝上买了一件东西
查看>>
发布一个 Linux 下的 C++ 多线程库
查看>>
Python序列类型
查看>>
再谈ThinkPHP
查看>>
Hibernate问题浅析
查看>>
出现访问apache资源直接下载php文件的解决办法-----yum 安装 php mysql
查看>>
七种Mysql表类型
查看>>
归并与归并排序
查看>>