0

I cannot create Kafka topic from GCE

in GEC

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
aa@kafka-1-vm:~$ sudo systemctl restart kafka

aa@kafka-1-vm:~$ bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test_cdc
-bash: bin/kafka-topics.sh: No such file or directory

aa@kafka-1-vm:~$ kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --
topic test_cdc

Exception in thread "main" joptsimple.UnrecognizedOptionException: bootstrap-server is not a recognized option
        at joptsimple.OptionException.unrecognizedOption(OptionException.java:108)
        at joptsimple.OptionParser.handleLongOptionToken(OptionParser.java:510)
        at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:56)
        at joptsimple.OptionParser.parse(OptionParser.java:396)
        at kafka.admin.TopicCommand$TopicCommandOptions.<init>(TopicCommand.scala:361)
        at kafka.admin.TopicCommand$.main(TopicCommand.scala:44)
        at kafka.admin.TopicCommand.main(TopicCommand.scala) 
Robin Moffatt
  • 30,382
  • 3
  • 65
  • 92
Thuy Le
  • 11
  • 6

2 Answers2

0

If you use version older than 2.2 you should use "--zookeeper" option and pass connection string to zookeeper (check your kafka version).

Command would be something like this: kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test_cdc

[before your command] kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test_cdc

0

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 tutorialGB --bootstrap-server localhost:9092

Created topic tutorialGB.

To checklist of topic created

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

tutorialGB

GirishBabuC
  • 1,267
  • 15
  • 20