hadoop_异常_01_ Unable to determine address of the host-falling back to "localhost" address java.net.UnknownHostException: rayner
一、异常现象
安装好hadoop之后,执行格式化namenode命令时,抛出以下异常:
18/03/21 21:02:10 WARN net.DNS: Unable to determine local hostname -falling back to "localhost" java.net.UnknownHostException: rayner: rayner at java.net.InetAddress.getLocalHost(InetAddress.java:1475) at org.apache.hadoop.net.DNS.resolveLocalHostname(DNS.java:284) at org.apache.hadoop.net.DNS.<clinit>(DNS.java:61) at org.apache.hadoop.hdfs.server.namenode.NNStorage.newBlockPoolID(NNStorage.java:991) at org.apache.hadoop.hdfs.server.namenode.NNStorage.newNamespaceInfo(NNStorage.java:600) at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:162) at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:1125) at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1567) at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1694) Caused by: java.net.UnknownHostException: rayner at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1295) at java.net.InetAddress.getLocalHost(InetAddress.java:1471) ... 8 more 18/03/21 21:02:10 WARN net.DNS: Unable to determine address of the host-falling back to "localhost" address java.net.UnknownHostException: rayner: rayner at java.net.InetAddress.getLocalHost(InetAddress.java:1475) at org.apache.hadoop.net.DNS.resolveLocalHostIPAddress(DNS.java:307) at org.apache.hadoop.net.DNS.<clinit>(DNS.java:62) at org.apache.hadoop.hdfs.server.namenode.NNStorage.newBlockPoolID(NNStorage.java:991) at org.apache.hadoop.hdfs.server.namenode.NNStorage.newNamespaceInfo(NNStorage.java:600) at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:162) at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:1125) at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1567) at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1694) Caused by: java.net.UnknownHostException: rayner at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1295) at java.net.InetAddress.getLocalHost(InetAddress.java:1471) ... 8 more
二、异常原因
是因为更改了虚拟机的hostname
vim /etc/sysconfig/network
而/etc/hosts 下的文件没有修改
三、异常解决
(1)编辑 /etc/hosts 文件
vim /etc/hosts
(2)将 主机IP 和 对应的主机名称 进行映射
添加下图红框中内容
192.168.1.102 rayner
三、参考资料
1.Unable to determine local hostname -falling back to "localhost"