转载请注明出处:http://blog.csdn.net/l1028386804/article/details/79194106
一、问题
用kfafka命令:./kafka-server-start.sh ../config/server.properties &启动时报以下错误:
[2018-01-28 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 anonfun$handleTopicMetadataRequest$2.apply(KafkaApis.scala:618)atkafka.server.KafkaApis 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 java.lang.Thread.run(Thread.java:662)
二、解决方案
解决办法是:
复制kafka/config路径下的server.properties文件为:server-1.properties和server-2.properties 并修改这三个文件的配置项:server.properties broker.id=0 port=9092 log.dir=/tmp/kafka-logs-0 host.name=localhost server-1.properties broker.id=1 port=9093 log.dir=/tmp/kafka-logs-1 host.name=localhost server-2.properties broker.id=2 port=9094 log.dir=/tmp/kafka-logs-2 host.name=localhostbroker.id、port、log.dir在这三个配置项中都不一样。 修改完成之后启动:
nohup ./kafka-server-start.sh ../config/server.properties & nohup ./kafka-server-start.sh ../config/server-1.properties & nohup ./kafka-server-start.sh ../config/server-2.properties &前一个启动可能还会报这个错,继续启动,都启动成功之后这个问题就解决了!
精彩评论