Creating and Deleting the Topics

How to Create and Delete Topic in Kafka using Ubuntu?

Please make sure that Zookeeper and Kafka server are running.

Getting Started

I) Creating Topics

kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic first_topic --create --partitions 3 --replication-factor 1

Check the list of topics created.

kafka-topics.sh --zookeeper 127.0.0.1:2181 --list

Get more information on a specific Topic

kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic first_topic --describe

Creating a second Topic

kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic second_topic --create --partitions 6 --replication-factor 1

Deleting the topic

  1. List all topics

kafka-topics.sh --zookeeper 127.0.0.1:2181 --list

2. Delete the topic

kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic second_topic --delete

→ by default the delete.topic.enable is set true.

3. Verify the deletion

kafka-topics.sh — zookeeper 127.0.0.1:2181 --list

Summary: You have learned to Create and Delete the Topic.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store