Java 执行 kafka-console-consumer.sh 时,zookeeper 不是可识别的选项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53428903/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 00:47:34  来源:igfitidea点击:

zookeeper is not a recognized option when executing kafka-console-consumer.sh

javaapache-kafkaapache-zookeeper

提问by xingbin

I'm learning how to use kafka from this link(except I'm using port 2182 in zookeeper),

我正在学习如何从此链接使用 kafka (除了我在 zookeeper 中使用端口 2182),

but it shows:

但它显示:

zookeeper is not a recognized option

动物园管理员不是公认的选项

after executing:

执行后:

sudo ./bin/kafka-console-consumer.sh --topic test --zookeeper localhost:2182

须藤 ./bin/kafka-console-consumer.sh --topic test --zookeeper 本地主机:2182

How to fix it?

如何解决?

Env:

环境:

kafka_2.11-2.1.0
zookeeper-3.4.10

采纳答案by xingbin

I found the answer in the officialsite.

我在官方网站上找到了答案。

Option zookeeperis deprecated, use --bootstrap-serverinstead.

选项zookeeper已弃用,请--bootstrap-server改用。

Now it works:

现在它的工作原理:

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

回答by Gurpreet Singh

For windows users use

对于 Windows 用户使用

bin/kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning

回答by aditya

For windows

窗户用

To start zookeeper

启动动物园管理员

C:\kafka-2.12>.\bin\windows\zookeeper-server-start.bat .\config\server.properties

To start Kafka Broker

启动Kafka Broker

C:\kafka-2.12>.\bin\windows\kafka-server-start.bat .\config\server.properties

To Create topic

创建主题

C:\kafka-2.12\bin\windows>kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

Start Producer

开始制作人

C:\kafka-2.12\bin\windows>kafka-console-producer.bat --broker-list localhost:9092 --topic test

To create consumer

创建消费者

C:\kafka-2.12\bin\windows>kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning

Topic creation With multi partition with replication factor 1

使用复制因子为 1 的多分区创建主题

C:\kafka-2.12\bin\windows>kafka-topics --zookeeper localhost:2181 --topic first_topic --create --partitions 3 --replication-factor 1

To get the list of topic created in system

获取系统中创建的主题列表

C:\kafka-2.12\bin\windows>kafka-topics --zookeeper localhost:2181 --list