kafka在搭建完全分布式集群的过程中,主机把Kafka包发送到从机,修改配置文件后出现kafka进程启动失败的情况,异常的代码如下所示:

[2019-10-14 11:08:51,263] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper)
[2019-10-14 11:08:51,263] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper)
[2019-10-14 11:08:51,263] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper)
[2019-10-14 11:08:51,263] INFO Client environment:os.arch=amd64 (org.apache.zookeeper.ZooKeeper)
[2019-10-14 11:08:51,263] INFO Client environment:os.version=2.6.32-431.el6.x86_64 (org.apache.zookeeper.ZooKeeper)
[2019-10-14 11:08:51,266] INFO Client environment:user.name=root (org.apache.zookeeper.ZooKeeper)
[2019-10-14 11:08:51,266] INFO Client environment:user.home=/root (org.apache.zookeeper.ZooKeeper)
[2019-10-14 11:08:51,266] INFO Client environment:user.dir=/export/servers/kafka_2.11-2.1.1/config (org.apache.zookeeper.ZooKeeper)
[2019-10-14 11:08:51,268] INFO Initiating client connection, connectString=192.168.141.130:2181,192.168.141.140:2181,192.168.141.150:2181 sessionTimeout=6000 watcher=kafka.zookeeper.ZooKeeperClient$ZooKeeperClientWatcher$@1623b78d (org.apache.zookeeper.ZooKeeper)
[2019-10-14 11:08:51,308] INFO [ZooKeeperClient] Waiting until connected. (kafka.zookeeper.ZooKeeperClient)
[2019-10-14 11:08:51,315] INFO Opening socket connection to server master.hadoop.com/192.168.141.130:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2019-10-14 11:08:51,329] INFO Socket connection established to master.hadoop.com/192.168.141.130:2181, initiating session (org.apache.zookeeper.ClientCnxn)
[2019-10-14 11:08:51,340] INFO Session establishment complete on server master.hadoop.com/192.168.141.130:2181, sessionid = 0x16dc837c4350002, negotiated timeout = 6000 (org.apache.zookeeper.ClientCnxn)
[2019-10-14 11:08:51,369] INFO [ZooKeeperClient] Connected. (kafka.zookeeper.ZooKeeperClient)
[2019-10-14 11:08:51,996] INFO Cluster ID = uY2mOQcSRAecyBnDLqDl1g (kafka.server.KafkaServer)
[2019-10-14 11:08:52,003] ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka.common.InconsistentBrokerIdException: Configured broker.id 2 doesn't match stored broker.id 0 in meta.properties. If you moved your data, make sure your configured broker.id matches. If you intend to create a new broker, you should remove all data in your data directories (log.dirs).
        at kafka.server.KafkaServer.getBrokerIdAndOfflineDirs(KafkaServer.scala:686)
        at kafka.server.KafkaServer.startup(KafkaServer.scala:209)
        at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
        at kafka.Kafka$.main(Kafka.scala:75)
        at kafka.Kafka.main(Kafka.scala)
[2019-10-14 11:08:52,006] INFO shutting down (kafka.server.KafkaServer)
[2019-10-14 11:08:52,008] INFO [ZooKeeperClient] Closing. (kafka.zookeeper.ZooKeeperClient)
[2019-10-14 11:08:52,014] INFO EventThread shut down for session: 0x16dc837c4350002 (org.apache.zookeeper.ClientCnxn)
[2019-10-14 11:08:52,014] INFO Session: 0x16dc837c4350002 closed (org.apache.zookeeper.ZooKeeper)
[2019-10-14 11:08:52,016] INFO [ZooKeeperClient] Closed. (kafka.zookeeper.ZooKeeperClient)
[2019-10-14 11:08:52,019] INFO shut down completed (kafka.server.KafkaServer)
[2019-10-14 11:08:52,020] ERROR Exiting Kafka. (kafka.server.KafkaServerStartable)
[2019-10-14 11:08:52,025] INFO shutting down (kafka.server.KafkaServer)

kafka启动异常的原因是,主机的Kafka配置完成后进行了相关的测试,日志文件中生成了主机相应的文件,造成从机启动Kafka进程的时候broker.id 不能匹配meta.properties造成的。

解决方案:进入自己的配置文件conf下面,找到自己的server.properties配置,编辑查看自己日志文件的配置目录,然后删除日志文件下面主机生成的文件,然后重新启动Kafka就可以了。
日志文件的配置目录如下:在这里插入图片描述
主机生成的日志文件:
在这里插入图片描述
重新启动后生成的文件信息:
在这里插入图片描述
重新生成了meta.properties文件中有了broker.id的信息
在这里插入图片描述

Logo

Kafka开源项目指南提供详尽教程,助开发者掌握其架构、配置和使用,实现高效数据流管理和实时处理。它高性能、可扩展,适合日志收集和实时数据处理,通过持久化保障数据安全,是企业大数据生态系统的核心。

更多推荐