今天在运行以下命令

hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar grep input output 'dfs[a-z.]+'

因为之前我改了主机名为master1

报错

19/03/16 16:12:59 INFO Configuration.deprecation: session.id is deprecated. Instead, use dfs.metrics.session-id
19/03/16 16:12:59 INFO jvm.JvmMetrics: Initializing JVM Metrics with processName=JobTracker, sessionId=
19/03/16 16:13:19 INFO metrics.MetricsUtil: Unable to obtain hostName
java.net.UnknownHostException: master1: master1: Temporary failure in name resolution
        at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
        at org.apache.hadoop.metrics.MetricsUtil.getHostName(MetricsUtil.java:95)
        at org.apache.hadoop.metrics.MetricsUtil.createRecord(MetricsUtil.java:84)
        at org.apache.hadoop.metrics.jvm.JvmMetrics.<init>(JvmMetrics.java:87)
        at org.apache.hadoop.metrics.jvm.JvmMetrics.init(JvmMetrics.java:78)
        at org.apache.hadoop.metrics.jvm.JvmMetrics.init(JvmMetrics.java:65)
        at org.apache.hadoop.mapred.LocalJobRunnerMetrics.<init>(LocalJobRunnerMetrics.java:40)

.........

翻译为

19/03/16 16:16:13信息配置。id被弃用。相反,使用dfs.metrics.session-id
19/03/16 16:16:13信息jvm。JvmMetrics:使用processName=JobTracker、sessionId=初始化JVM指标
19/03/16 16:16:33信息度量。MetricsUtil:无法获得主机名
unknownhostexception: master1: master1:名称解析暂时失败

unknownhostexception指的是主机名解析失败

在/etc/hosts中添加主机名master1后,或者修改主机名为master皆可

[root@master1 output]# cat /etc/hosts
127.0.0.1  master1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1        master1 localhost localhost.localdomain localhost6 localhost6.localdomain6