This tutorial guides you on how to fix zookeeper is not a recognized option while running kafka-console-consumer.sh script to consume messages from a Kafka topic.
zookeeper is not a recognized option – Issue
$ sudo /usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties
Once server is started, wanted to verify that setup is working fine. Therefore, tried to create a test topic, produced messages and consume the same.
As a first step, created a topic called “test” topic by executing the following command.
$ /usr/local/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test Created topic test.
Next, verified the topic created.
$ sudo /usr/local/kafka/bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic test Topic: test PartitionCount: 1 ReplicationFactor: 1 Configs: Topic: test Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Then, produced messages to the test topic as shown below.
$ sudo /usr/local/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test >Test msg 1 >Test msg 2 >Test msg 3 >Test msg 4
Finally, tried to consume messages from the topic “test” by executing the following command. But it resulted in throwing message which says “zookeeper is not a recognized option” as shown below.
$ sudo /usr/local/kafka/bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning zookeeper is not a recognized option
Fix – zookeeper is not a recognized option
After looking at the Apache Kafka documentation, I came to know that the option –zookeeper is deprecated and need to use –bootstrap-server instead as shown below.
$ sudo /usr/local/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning Test msg 1 Test msg 2 Test msg 3 Test msg 4 ^C Processed a total of 4 messages $
Note, you need to be sudo user to run the above commands.
That’s it. You had learnt how to fix zookeeper is not a recognized option issue while executing kafka-console-consumer.sh script to consume messages from a Kafka topic.
Hope it helped 🙂
- How to Start Stop Restart MariaDB on Linux OS ?
- How to set or change root password in Ubuntu Linux ?
- Putty Fatal Error No supported authentication methods available
- How to find which users belongs to a specific group in linux
- Give write permissions for specific user or group for specific folder in linux
- How to unzip a zip file from Terminal (Google Cloud Shell)
- Build a Docker Image with a Dockerfile and Cloud Build in GCP?
- JMeter Testing : How to run 100 Requests per second
- MariaDB – How to set max_connections permanently ?
- How to create GCP project on Google Cloud Platform
- Is it possible to change Google Cloud Platform Project ID ?
- Create non-root SSH user account and provide access to specific folders
- MySQL : How to grant all privileges to the user on database ?
- Find Java JDK Path – OpenJDK Installed
- Replication factor: 1 larger than available brokers: 0 – Create Kafka Topic