This error occurs when creating topic. Create command:
[hw@node01 bin]$ ./kafka-topics.sh --create --topic first --zookeeper node01:2181 --partitions 3 --replication-factor 1
The error is as follows:;
Error while executing topic command : Replication factor: 3 larger than available brokers: 0. [2022-02-26 15:55:45,948] ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 3 larger than available brokers: 0. (kafka.admin.TopicCommand$)
Error reason: the problem occurs because the path stored by Kafka # broker in zookeeper is not the root directory, but the/Kafka # path
You can start the client of zookeeper to view the broker path of Kafka:
$ bin/zkCli.sh #Go to the client to view the path details $ ls -R /
Therefore, modify the command that you create Topic:
[hw@node01 bin]$ ./kafka-topics.sh --create --topic first --zookeeper node01:2181/kafka --partitions 1 --replication-factor 3