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

4

87

I'm learning how to use Kafka on this website link(except I'm using port 2182 in zookeeper), but it shows:

zookeeper is not a recognized option

after executing:

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

How to fix it?

Env:

kafka_2.11-2.1.0
zookeeper-3.4.10
Tertiary answered 22/11, 2018 at 10:30 Comment(1)
You don't need sudo to run these commandsRombert
T
213

I find the answer on the QUICKSTART:

Option zookeeper is deprecated, use --bootstrap-server instead.

Now it works:

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
Tertiary answered 22/11, 2018 at 10:42 Comment(3)
latest kafka using bootstrap-serverFiume
To create topic use kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic testPayola
Definitely worked! replaced --zookeeper with --bootstrap-server (btw, I'm using kafka 2.13-3.5.0)Scorpaenoid
A
20

For windows

To start zookeeper

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

To start 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

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

To get the description of topic created in system

C:\kafka-2.12\bin\windows>kafka-topics.bat --describe --zookeeper localhost:2181 --topic test

To delete topic test created in system

C:\kafka-2.12\bin\windows>kafka-run-class.bat kafka.admin.TopicCommand --delete --topic test --zookeeper localhost:2181

To read message from beginning of topic test created in system(version>2.0)

C:\kafka-2.12\bin\windows>kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginn
Astonied answered 14/10, 2019 at 7:12 Comment(0)
O
9

For windows users use

bin/kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
Oscillatory answered 9/1, 2019 at 12:7 Comment(1)
remove 'bin' and execute the command from 'bin/windows' folder.Ithyphallic
U
4

UPDATE

  • From version 2.1.* the previous answers may not work, always check the official documentation , this answer provided with version 3.1.0 .

For Linux kernel base systems

./kafka-topics.sh --create --topic yourTopicname --bootstrap-server localhost:9092

For Windows systems

./kafka-topics.bat --create --topic quickstart-events --bootstrap-server localhost:9092

No need to pass --from-beginning when there is no initial offset and overload the creation command with desired configs

Unstriped answered 25/3, 2022 at 11:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.