我有一些 Java 系统,我想在其中使用 Hadoop,但每当我使用此命令连接到本地主机时
hadoop fs -ls /
它总是会提示
java.net.UnknownHostException: local.localdomain: diginiqlinux.localdomain
at java.net.InetAddress.getLocalHost(InetAddress.java:1466)
编辑
这是我的 //etc/hosts
127.0.0.1 localhost
完整跟踪日志
[root@diginiqlinux ~]# hadoop fs -ls
13/12/30 16:44:36 INFO metrics.MetricsUtil: Unable to obtain hostName
java.net.UnknownHostException: diginiqlinux.localdomain: diginiqlinux.localdomai n
at java.net.InetAddress.getLocalHost(InetAddress.java:1466)
at org.apache.hadoop.metrics.MetricsUtil.getHostName(MetricsUtil.java:91 )
at org.apache.hadoop.metrics.MetricsUtil.createRecord(MetricsUtil.java:8 0)
at org.apache.hadoop.security.UserGroupInformation$UgiMetrics.<init>(Use rGroupInformation.java:102)
at org.apache.hadoop.security.UserGroupInformation.<clinit>(UserGroupInf ormation.java:208)
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:1757 )
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:1750 )
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1618)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:255)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:124)
at org.apache.hadoop.fs.FsShell.init(FsShell.java:86)
at org.apache.hadoop.fs.FsShell.run(FsShell.java:1813)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
at org.apache.hadoop.fs.FsShell.main(FsShell.java:1974)
Caused by: java.net.UnknownHostException: diginiqlinux.localdomain
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:894)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:128 6)
at java.net.InetAddress.getLocalHost(InetAddress.java:1462)
... 14 more
ls: Cannot access .: No such file or directory.
有什么解决方案可以连接本地主机吗?
答案1
在文件中为 localhost 添加条目 127.0.0.1 /etc/hosts
。
127.0.0.1 localhost
答案2
在 /etc/hosts 文件中,可能有一行127.0.1.1 [hostname]
。我会将其更改为127.0.0.1 [hostname]
。我相信这是 sudo 正常工作所必需的,并且通常存在问题。
http://wiki.apache.org/hadoop/ConnectionRefused
core-site.xml 也可以使用localhost
或hostname
,确保其配置正确。
<property>
<name>fs.defaultFS</name>
<value>hdfs://[hostname]:9000</value>
</property>