Deleting a Kafka Topic


Deleting a Kafka Topic

The following steps to delete a topic.

Steps to follow

Step 1 - Open a new terminal (CTRL + ALT + T) and change the directory to /usr/local/kafka




$ cd /usr/local/kafka

Step 2 - Start the zookeeper




$ ./bin/zookeeper-server-start.sh config/zookeeper.properties

Step 3 - Open a new terminal (CTRL + ALT + T) and change the directory to /usr/local/kafka




$ cd /usr/local/kafka

Step 4 - Start the kafka server




$ ./bin/kafka-server-start.sh config/server.properties

Step 5 - Open a new terminal (CTRL + ALT + T) and just type 'jps' (without quotes). It shows all the java processes that are running.

Here Kafka is the kafka server and QuorumPeerMain is zookeeper process.

Step 6 - Open a new terminal (CTRL + ALT + T) and change the directory to /usr/local/kafka




$ cd /usr/local/kafka

Step 7 - Create a topic.




$ ./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic Hello-Kafka

Step 8 - List topics. (optional)




$ ./bin/kafka-topics.sh --list --zookeeper localhost:2181

Step 9 - Delete a topic.




$ ./bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic Hello-kafka

NOTE

To delete a topic, the below propery must be true in /usr/local/kafka/config/server.properties file.




delete.topic.enable = true

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *