3

I am new to Kafka and trying to create a new topic on my local machine. I am following this https://medium.com/@maftabali2k13/setting-up-a-kafka-cluster-on-ec2-1b37144cb4e

  1. Start zookeeper
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties

Start kafka-server

bin/kafka-server-start.sh -daemon config/server.properties

Create a topic

bin/kafka-topics.sh --create -–bootstrap-server localhost:9092 -–replication-factor 1 -–partitions 1 --topic jerry

but when creating the topic, I am getting the following error


Exception in thread "main" joptsimple.UnrecognizedOptionException: – is not a recognized option
        at joptsimple.OptionException.unrecognizedOption(OptionException.java:108)
        at joptsimple.OptionParser.validateOptionCharacters(OptionParser.java:633)
        at joptsimple.OptionParser.handleShortOptionCluster(OptionParser.java:528)
        at joptsimple.OptionParser.handleShortOptionToken(OptionParser.java:523)
        at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:59)
        at joptsimple.OptionParser.parse(OptionParser.java:396)
        at kafka.admin.TopicCommand$TopicCommandOptions.<init>(TopicCommand.scala:552)
        at kafka.admin.TopicCommand$.main(TopicCommand.scala:49)
        at kafka.admin.TopicCommand.main(TopicCommand.scala)

I had seen the following Why is kafka not creating a topic? bootstrap-server is not a recognized option But I cant find an answer to my problem here as the error given is different. Is there some stuff that I am missing here?

Stan11
  • 274
  • 3
  • 11

3 Answers3

5

I've used your command and had same issue:

bin/kafka-topics.sh --create -–bootstrap-server localhost:9092 -–replication-factor 1 -–partitions 1 --topic jerry

If you look closer to your command you will see, that before options: bootstrap-server, replication-factor and partitions are strange characters.

I think you use copy/paste method and some strange characters were added:

Following command should work: bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic jerry

Best way is to write it by your own :).

Bartosz Wardziński
  • 6,185
  • 1
  • 19
  • 30
  • Yaaa Thanks ..It worked . Yes I had done copy/paste. Just like u told, I there were some strange characters added. – Stan11 Sep 05 '19 at 08:00
1

New version of Kafka no longer required ZooKeeper connection string. Use --bootstrap-server localhost:9092 instead of --zookeeper localhost:2181.

For windows: kafka-topics.bat --create -–bootstrap-server localhost:9092 -–replication-factor 1 -–partitions 1 --topic topic-name

For linux : kafka-topics.sh --create -–bootstrap-server localhost:9092 -–replication-factor 1 -–partitions 1 --topic topic-name

-1

In the latest version kafka_2.12-3.1.0 (2022) after unzipping and setting the properties and logs. keep the Kafka folder on the C drive and always run the command prompt with 'run as administrator'. The .bat file is for windows

Terminal 1

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

Terminal 2

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

Terminal 3

C:\kafka\bin\windows>kafka-topics.bat --create --topic tutorialspedia --bootstrap-server localhost:9092

Created topic tutorialspedia.

To checklist of topic created

C:\kafka\bin\windows>kafka-topics.bat --list --bootstrap-server localhost:9092

tutorialspedia

GirishBabuC
  • 1,267
  • 15
  • 20