解决ERROR org.apache.hadoop.mapreduce.v2.app.RMContainerAllocator:Exception while unregistering问题

报错信息:

ERROR [Thread-723] org.apache.hadoop.mapreduce.v2.app.RMContainerAllocator:Exception while unregistering
java.lang.NullPointerException
  at org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil.getApplicationWebURLOnJHSWithoutScheme(MRWebAppUtil.java:140)

这是Hadoop的一个bug。点击查看:https://issues.apache.org/jira/browse/MAPREDUCE-6213

解决:

修改hadoop-mapreduce-client-common-2.7.7.jar中的org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil类

if (address.getAddress().isAnyLocalAddress() || 
        address.getAddress().isLoopbackAddress()) {
      sb.append(InetAddress.getLocalHost().getCanonicalHostName());
} else {
  sb.append(address.getHostName());
}

改成:

if (address.getAddress() != null && (address.getAddress().isAnyLocalAddress() || 
        address.getAddress().isLoopbackAddress())) {
      sb.append(InetAddress.getLocalHost().getCanonicalHostName());
} else {
  sb.append(address.getHostName());
}
如果觉得我的文章对你有用,请随意赞赏