📖 Scenario: You are managing a Kafka cluster that stores messages for different applications. Sometimes, old topics are no longer needed and should be deleted to free up space and keep the system clean.
🎯 Goal: You will learn how to delete a Kafka topic safely and verify that the topic has been removed from the cluster.
📋 What You'll Learn
Kafka cluster is running locally
Kafka command-line tools are available
Basic knowledge of terminal commands
💡 Why This Matters
🌍 Real World
Kafka topics store streams of data for applications. Removing unused topics helps keep the system clean and saves storage.
💼 Career
Kafka administrators and DevOps engineers often need to manage topics, including deleting old ones to maintain cluster health.
Progress0 / 4 steps
1
Create a Kafka topic named old_topic
Use the Kafka command-line tool to create a topic called old_topic with 1 partition and a replication factor of 1.
Kafka
Hint
Use kafka-topics.sh --create with the right flags to create the topic.
2
Enable topic deletion in Kafka configuration
Set the Kafka broker configuration property delete.topic.enable to true to allow topic deletion.
Kafka
Hint
Find the server.properties file and add or update delete.topic.enable=true. Restart Kafka after.
3
Delete the Kafka topic named old_topic
Use the Kafka command-line tool to delete the topic called old_topic.
Kafka
Hint
Use kafka-topics.sh --delete --topic old_topic to remove the topic.
4
Verify that the topic old_topic is deleted
List all Kafka topics and confirm that old_topic no longer appears.
Kafka
Hint
Use kafka-topics.sh --list and check that old_topic is not shown.
Practice
(1/5)
1. What is the correct Kafka configuration to enable topic deletion?
easy
A. topic.delete.enabled=false
B. enable.topic.removal=false
C. delete.topic.enable=true
D. allow.topic.delete=no
Solution
Step 1: Understand Kafka topic deletion setting
The Kafka broker must have a configuration that explicitly allows topic deletion.
Step 2: Identify the correct configuration key
The correct key is delete.topic.enable and it must be set to true to allow deletion.