kafka报错——Error while executing topic command : Replication factor: 3 larger than available brokers: 0.
创建 Topic 时出现该错误,创建命令:
[hw@node01 bin]$ ./kafka-topics.sh --create --topic first --zookeeper node01:2181 --partitions 3 --replication-factor 1
错误如下;
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$)
错误原因:出现的问题是因为Kafka Broker 在 zookeeper 存储的路径并不是根目录,而是 /kafka 路径
可以启动zookeeper得客户端查看kafka 的Broker路径:
$ bin/zkCli.sh
#进入客户端查看路径详情
$ ls -R /
因此,修改创建 Topic 的指令:
[hw@node01 bin]$ ./kafka-topics.sh --create --topic first --zookeeper node01:2181/kafka --partitions 1 --replication-factor 3