Creating and Deleting the Topics

How to Create and Delete Topic in Kafka using Ubuntu?

Learn how to create and delete the topics.

Sagar Kudu

--

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.

--

--

Sagar Kudu

I am Full Stack Java Developer @ Tata Strive | Get blogs and tutorials related to the (React | Kafka | DevOps) | Connect https://www.linkedin.com/in/sagarkudu/