用kfafka命令:./kafka-server-start.sh ../config/server.properties &启动时报以下错误:
[2016-04-27 21:54:44,745] ERROR [KafkaApi-100] error when handling request Name: TopicMetadataRequest; Version: 0; CorrelationId: 1496; ClientId: producer-1; Topics: Interation,Booksheet (kafka.server.KafkaApis)
kafka.admin.AdminOperationException: replication factor: 1 larger than available brokers: 0
at kafka.admin.AdminUtils$.assignReplicasToBrokers(AdminUtils.scala:70) at kafka.admin.AdminUtils$.createTopic(AdminUtils.scala:155) at kafka.server.KafkaApis[Math Processing Error]anonfun$handleTopicMetadataRequest$2.apply(KafkaApis.scala:612) at scala.collection.immutable.Set$Set2.foreach(Set.scala:106) at kafka.server.KafkaApis.handleTopicMetadataRequest(KafkaApis.scala:612) at kafka.server.KafkaApis.handle(KafkaApis.scala:71) at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:42)at .lang.Thread.run(Thread.java:662)
解决办法是:
复制kafka/config路径下的server.properties文件为:server-1.properties和server-2.properties
并修改这两个文件的配置项:
config/server-1.properties: broker.id=1 listeners=PLAINTEXT://:9093 log.dir=/tmp/kafka-logs-1config/server-2.properties: broker.id=2 listeners=PLAINTEXT://:9094 log.dir=/tmp/kafka-logs-2
broker.id、port、log.dir在这三个配置项中都不一样。
修改完成之后启动:
./kafka-server-start.sh ../config/server.properties &
./kafka-server-start.sh ../config/server-1.properties &
./kafka-server-start.sh ../config/server-2.properties &
前一个启动可能还会报这个错,继续启动,都启动成功之后这个问题就解决了!
官方文档参考地址: