Search code examples
apache-kafkaapache-zookeeperkafka-topic

Why is kafka not creating a topic? - is not a recognized option


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?


Solution

  • 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 :).