Getting error while creating kafka topic from command line The syntax of the command is incorrect

Viewed 692

Hi Folks I am trying to create a kafka topic using kafka-topic command-line tool, but it is kept on showing "the syntax of the command is incorrect" I am using Kafka version 2.5.0 (Commit:66563e712b0b9f84) below are the commands that I tried but each time I am getting the same error.

 1.  .\kafka-topics.bat  --bootstrap-server broker:9092 --topic topic1 --create --replication-factor 1 --partitions 1
 2.  .\kafka-topics.bat --create --topic ngdev-topic --zookeeper localhost:2181 --replication-factor 1 --partitions 3
 3. .\kafka-topics.bat -create -zookeeper localhost:2181 -replication-factor 1 -partitions 1 -topic sql-insert
 4. .\kafka-topics.bat  --bootstrap-server localhost:9092 --create --topic test1 --partitions 1 --replication-factor 1
1 Answers

The command is kafka-topics --create, which has sub-arguments. Attempt 3 shown is the closest, but only uses one dash for all arguments instead of two.

Next, you give the topic name --topic X

Then, give the cluster connection string, ideally using --bootstrap-server since the Zookeeper flag is deprecated

Then replication-factor is optional, and will use the value defined in the server.properties file for all topics. Same for partitions, but it's always good to set this

Overall, don't run Kafka on windows outside of WSL2

Related