Command to Create and Delete a Kafka Topic
Creating a Kafka Topic
To create a topic, go to the Kafka folder and run the following command:
Ubuntu/Linux/Mac
$ bin/kafka-topics.sh --create --topic my-topic-name --partitions 1 --replication-factor 1 --bootstrap-server localhost:9092
Windows
> bin\windows\kafka-topics.bat --create --topic my-topic-name --partitions 1 --replication-factor 1 --bootstrap-server localhost:9092
Deleting a Kafka Topic
To delete a topic, simply go to the Kafka folder and run the following command:
Ubuntu/Linux/Mac
$ bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic my-topic-name
Windows
> bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --delete --topic my-topic-name