When a Kafka Topic Fails to Be Created, "replication factor larger than available brokers" Is Displayed
Symptom
When running the following command on the Kafka client to create topics, it is found that the topics cannot be created.
kafka-topics.sh --create --replication-factor 2 --partitions 2 --topic test --zookeeper 192.168.234.231:2181
The error message "replication factor larger than available brokers" is displayed.
See the following:
Error while executing topic command : replication factor: 2 larger than available brokers: 0 [2017-09-17 16:44:12,396] ERROR kafka.admin.AdminOperationException: replication factor: 2 larger than available brokers: 0 at kafka.admin.AdminUtils$.assignReplicasToBrokers(AdminUtils.scala:117) at kafka.admin.AdminUtils$.createTopic(AdminUtils.scala:403) at kafka.admin.TopicCommand$.createTopic(TopicCommand.scala:110) at kafka.admin.TopicCommand$.main(TopicCommand.scala:61) at kafka.admin.TopicCommand.main(TopicCommand.scala) (kafka.admin.TopicCommand$)
Possible Causes
- The Kafka service is not running.
- The available Broker of the Kafka service is smaller than the configured replication-factor.
- The ZooKeeper address parameter in the client command is incorrectly configured.
Cause Analysis
- After the client command is run, "replication factor larger than available brokers" is reported.
Error while executing topic command : replication factor: 2 larger than available brokers: 0 [2017-09-17 16:44:12,396] ERROR kafka.admin.AdminOperationException: replication factor: 2 larger than available brokers: 0 at kafka.admin.AdminUtils$.assignReplicasToBrokers(AdminUtils.scala:117) at kafka.admin.AdminUtils$.createTopic(AdminUtils.scala:403) at kafka.admin.TopicCommand$.createTopic(TopicCommand.scala:110) at kafka.admin.TopicCommand$.main(TopicCommand.scala:61) at kafka.admin.TopicCommand.main(TopicCommand.scala) (kafka.admin.TopicCommand$)
- Check whether the Kafka service is in the normal state on Manager and whether the current available Broker is smaller than the configured replication-factor.
- Check whether the ZooKeeper address in the client command is correct. Check the Kafka information stored in ZooKeeper. The path (Znode) should be suffixed with /kafka. It is found that /kafka is missing in the configuration.
[root@10-10-144-2 client]# kafka-topics.sh --create --replication-factor 2 --partitions 2 --topic test --zookeeper 192.168.234.231:2181
Solution
- Ensure that the Kafka service is in the normal state and the available Broker is not less than the configured replication-factor.
- Add /kafka to the ZooKeeper address in the command.
[root@10-10-144-2 client]# kafka-topics.sh --create --replication-factor 1 --partitions 2 --topic test --zookeeper 192.168.234.231:2181/kafka
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.