配置如下:
############################# Server Basics #############################
# The id of the broker. This must be set to a unique integer for each broker.
broker.id=1
############################# Log Basics #############################
# A comma seperated list of directories under which to store log files
log.dirs=/tmp/kafka-logs
启动后报错如下:
[2016-04-19 07:57:34,064] FATAL Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka.common.InconsistentBrokerIdException: Configured brokerId 1 doesn't match stored brokerId 0 in meta.properties
at kafka.server.KafkaServer.getBrokerId(KafkaServer.scala:630)
at kafka.server.KafkaServer.startup(KafkaServer.scala:175)
at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:37)
at kafka.Kafka$.main(Kafka.scala:67)
at kafka.Kafka.main(Kafka.scala)
[2016-04-19 07:57:34,065] INFO shutting down (kafka.server.KafkaServer)
[2016-04-19 07:57:34,075] INFO Shutting down. (kafka.log.LogManager)
[2016-04-19 07:57:34,105] INFO Shutdown complete. (kafka.log.LogManager)
[2016-04-19 07:57:34,106] INFO Terminate ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2016-04-19 07:57:34,110] INFO EventThread shut down (org.apache.zookeeper.ClientCnxn)
[2016-04-19 07:57:34,111] INFO Session: 0x3540890f9900003 closed (org.apache.zookeeper.ZooKeeper)
[2016-04-19 07:57:34,112] INFO shut down completed (kafka.server.KafkaServer)
[2016-04-19 07:57:34,122] FATAL Fatal error during KafkaServerStartable startup. Prepare to shutdown (kafka.server.KafkaServerStartable)
kafka.common.InconsistentBrokerIdException: Configured brokerId 1 doesn't match stored brokerId 0 in meta.properties
at kafka.server.KafkaServer.getBrokerId(KafkaServer.scala:630)
at kafka.server.KafkaServer.startup(KafkaServer.scala:175)
at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:37)
at kafka.Kafka$.main(Kafka.scala:67)
at kafka.Kafka.main(Kafka.scala)
[2016-04-19 07:57:34,123] INFO shutting down (kafka.server.KafkaServer)
解决方法是让meta.properties文件中的brokerId与server.properties中的brokerId保持一致。meta.properties文件位于log.dirs所配置的路径:
/tmp/kafka-logs
根据自己的配置来更改即可解决。