Kafka报错:Exception in thread “main“ joptsimple.UnrecognizedOptionException: zookeeper is not a recogn

前言

kafka版本过高所致,2.2+=的版本,已经不需要依赖zookeeper来查看/创建topic,新版本使用 --bootstrap-server替换老版本的 --zookeeper-server

[root@CentOS6 kafka_2.13-3.3.1]# bin/kafka-topics.sh --list --zookeeper-server kafkahost:9092
Exception in thread "main" joptsimple.UnrecognizedOptionException: zookeeper-server is not a recognized option
        at joptsimple.OptionException.unrecognizedOption(OptionException.java:108)
        at joptsimple.OptionParser.handleLongOptionToken(OptionParser.java:510)
        at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:56)
        at joptsimple.OptionParser.parse(OptionParser.java:396)
        at kafka.admin.TopicCommand$TopicCommandOptions.(TopicCommand.scala:567)
        at kafka.admin.TopicCommand$.main(TopicCommand.scala:47)
        at kafka.admin.TopicCommand.main(TopicCommand.scala)
[root@CentOS6 kafka_2.13-3.3.1]# 

Kafka报错:Exception in thread “main“ joptsimple.UnrecognizedOptionException: zookeeper is not a recogn_第1张图片

解决方案

把下面命令中的 --zookeeper-server替换为 --bootstrap-server就可以了,如下图所示:

1、查看主题

 bin/kafka-topics.sh --list --bootstrap-server kafkahost:9092

Kafka报错:Exception in thread “main“ joptsimple.UnrecognizedOptionException: zookeeper is not a recogn_第2张图片

注:上图中的kafkahost,是我自己在etc/host中配置的,可通过vim /etc/host去编辑

 当然,你也可以通过ifconfig获取虚拟IP后,把kafkahost替换为虚拟IP。

2、创建主题

bin/kafka-topics.sh --bootstrap-server kafkahost:9092 --create --topic talking --partitions 1

bin/kafka-topics.sh --bootstrap-server kafkahost:9092 --list

Kafka报错:Exception in thread “main“ joptsimple.UnrecognizedOptionException: zookeeper is not a recogn_第3张图片

尾言

时代在进步,版本在更迭,只有不断学习,才能感受时代的脚步,加油!

附注

1、ZK/Zookeeper的下载和安装 | 真/伪集群的快速搭建

2、Kafka锦集(一):Kafka的安装和介绍,总结的很详细

3、配置Kafka的监听 | kafka启动报错:java.net.UnknownHostException 

你可能感兴趣的:(#,Kafka,kafka,java-zookeeper,zookeeper)