首页  |  知识库  |  资源下载  |  在线工具  |  A-Z  •  JAR  •  名词查         

解决启动kafka报"java.net.UnknownHostException: centos6.7.s2: centos6.7.s2: 未知的名称或服务..java.lang.ExceptionInInitializerError"异常错误

标签:UnknownHostException,kafka启动失败,未知的名称或服务,ExceptionInInitializerError     发布时间:2019-03-17   

一、异常描述

关于kafka启动时报"java.net.UnknownHostException: centos6.7.s2: centos6.7.s2: 未知的名称或服务...java.lang.ExceptionInInitializerError"异常错误,详情日志如下>>

[root@centos6 kafka_2.11-0.9.0.1]# bin/kafka-server-start.sh   config/server.properties @b@[2019-03-17 12:16:53,387] INFO KafkaConfig values: @b@        request.timeout.ms = 30000@b@        log.roll.hours = 168@b@        inter.broker.protocol.version = 0.9.0.X@b@        log.preallocate = false@b@        security.inter.broker.protocol = PLAINTEXT@b@        controller.socket.timeout.ms = 30000@b@        broker.id.generation.enable = true@b@        ssl.keymanager.algorithm = SunX509@b@        ssl.key.password = null@b@        log.cleaner.enable = true@b@        ssl.provider = null@b@        num.recovery.threads.per.data.dir = 1@b@        ...@b@[2019-03-17 12:16:53,817] FATAL [Kafka Server 0], Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)@b@java.net.UnknownHostException: centos6.7.s2: centos6.7.s2: 未知的名称或服务@b@        at java.net.InetAddress.getLocalHost(InetAddress.java:1475)@b@        at kafka.server.KafkaHealthcheck$$anonfun$1.apply(KafkaHealthcheck.scala:55)@b@        at kafka.server.KafkaHealthcheck$$anonfun$1.apply(KafkaHealthcheck.scala:53)@b@        at scala.collection.MapLike$MappedValues.get(MapLike.scala:249)@b@        at scala.collection.MapLike$class.getOrElse(MapLike.scala:126)@b@        at scala.collection.AbstractMap.getOrElse(Map.scala:59)@b@        at kafka.server.KafkaHealthcheck.register(KafkaHealthcheck.scala:63)@b@        at kafka.server.KafkaHealthcheck.startup(KafkaHealthcheck.scala:45)@b@        at kafka.server.KafkaServer.startup(KafkaServer.scala:231)@b@        at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:37)@b@        at kafka.Kafka$.main(Kafka.scala:67)@b@        at kafka.Kafka.main(Kafka.scala)@b@Caused by: java.net.UnknownHostException: centos6.7.s2: 未知的名称或服务@b@        at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)@b@        at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)@b@        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1295)@b@        at java.net.InetAddress.getLocalHost(InetAddress.java:1471)@b@        ... 11 more@b@[2019-03-17 12:16:53,818] INFO [Kafka Server 0], shutting down (kafka.server.KafkaServer)@b@[2019-03-17 12:16:53,820] INFO [Socket Server on Broker 0], Shutting down (kafka.network.SocketServer)@b@[2019-03-17 12:16:53,822] INFO New leader is 0 (kafka.server.ZookeeperLeaderElector$LeaderChangeListener)@b@[2019-03-17 12:16:53,828] INFO [Socket Server on Broker 0], Shutdown completed (kafka.network.SocketServer)@b@[2019-03-17 12:16:53,828] INFO [Kafka Request Handler on Broker 0], shutting down (kafka.server.KafkaRequestHandlerPool)@b@[2019-03-17 12:16:53,839] WARN  (kafka.utils.CoreUtils$)@b@java.lang.ExceptionInInitializerError@b@        at kafka.server.KafkaRequestHandler.shutdown(KafkaRequestHandler.scala:67)@b@        at kafka.server.KafkaRequestHandlerPool$$anonfun$shutdown$2.apply(KafkaRequestHandler.scala:90)@b@        at kafka.server.KafkaRequestHandlerPool$$anonfun$shutdown$2.apply(KafkaRequestHandler.scala:89)@b@        at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)@b@        at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)@b@        at kafka.server.KafkaRequestHandlerPool.shutdown(KafkaRequestHandler.scala:89)@b@        at kafka.server.KafkaServer$$anonfun$shutdown$3.apply$mcV$sp(KafkaServer.scala:531)@b@        at kafka.utils.CoreUtils$.swallow(CoreUtils.scala:79)@b@        at kafka.utils.Logging$class.swallowWarn(Logging.scala:92)@b@        at kafka.utils.CoreUtils$.swallowWarn(CoreUtils.scala:51)@b@        at kafka.utils.Logging$class.swallow(Logging.scala:94)@b@        at kafka.utils.CoreUtils$.swallow(CoreUtils.scala:51)@b@        at kafka.server.KafkaServer.shutdown(KafkaServer.scala:531)@b@        at kafka.server.KafkaServer.startup(KafkaServer.scala:247)@b@        at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:37)@b@        at kafka.Kafka$.main(Kafka.scala:67)@b@        at kafka.Kafka.main(Kafka.scala)@b@Caused by: java.net.UnknownHostException: centos6.7.s2: centos6.7.s2: 未知的名称或服务@b@        at java.net.InetAddress.getLocalHost(InetAddress.java:1475)@b@        at kafka.network.RequestChannel$.<init>(RequestChannel.scala:39)@b@        at kafka.network.RequestChannel$.<clinit>(RequestChannel.scala)@b@        ... 17 more@b@Caused by: java.net.UnknownHostException: centos6.7.s2: 未知的名称或服务@b@        at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)@b@        at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)@b@        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1295)@b@        at java.net.InetAddress.getLocalHost(InetAddress.java:1471)@b@        ... 19 more

二、解决方法

如下操作所示,在"/etc/hosts"中增加"127.0.0.1   centos6.7.s2"未知域名的配置,具体如下所示

[root@centos6 kafka_2.11-0.9.0.1]# vim  /etc/hosts@b@127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4@b@::1         localhost localhost.localdomain localhost6 localhost6.localdomain6@b@127.0.0.1   centos6.7.s2