首页

解决启动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
<<推荐下载>>
  • (1) 阿里巴巴Java开发手册8种不同版本
  • (2) Web前端开发视频教程
  • (3) 30+明星讲师PPT课件分享一线大厂架构实战经验
  • (4) java开发_架构篇_视频资源分享_v2208
  • (5) java开发_高级篇_视频资源分享_v2208
  • (6) java开发_进阶篇(中级)_视频资源分享_v2208
  • (7) java开发_入门篇_视频资源分享_v2208
  • (8) 微信小程序开发视频1+167源码+实战demo等下载
  • (9) easy-shopping电子商务java源码(附脚本和安装文档说明)下载
  • (10) java常用的72份知名实用的电子书下载
  • (11) java开发性能优化资料整理大全(8份电子文档+3份实战优化)下载
  • (12) 9个常用的算法设计资料和100以上视频课件内容下载
  • (13) vue开发必备常用手册16件下载
  • (14) 21种不同技术集群方案(es、flink、redis、nginx、zk、lvs、kafka、mysql、k8s等)参考资料下载
  • (15) 20种技术代码规范(js/java/dba/阿里/华为/oracle/mysql等)参考资料下载
  • (16) 微服务五套资料(0-1,架构设计,springcloud,nacos等)下载
  • (17) 架构师(28知识图谱+3套简历模板+6套架构实战文档等)完整资料整理下载
  • (18) 大数据18套实战基础知识+8套简历模板下载
  • (19) 并发编程全套(7套+阿里巴巴+亿级实战等)实战资料下载
  • (20) Kafka九套学习整理知识点全套(面试+笔记+代码api+命令+容备等)资料下载
  • (21) java全套9个不同方向类型的面试题(基础+核心+大厂+架构师+近万套题库等)下载
  • (22) JAVA开发常用API帮助文档大全(超52种以上技术资料,高手必备)下载
  • (23) springcloud超详细139件全套学习实战资料( 视频课件+源码demo+文档资料等)下载
  • 更多推荐>>
  • <<热门文章>>