Delete topic in Kafka 0.8.1.1

I need to remove the test theme in Apache Kafka 0.8.1.1.

As stated in the documentation here , I did:

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

However, this leads to the following message:

 Command must include exactly one action: --list, --describe, --create or --alter 

How to remove this topic?

+82
apache-kafka
Jun 18 '14 at 14:12
source share
14 answers

Deleting a topic does not always work in 0.8.1.1

Removal should work in the next version, 0.8.2

 kafka-topics.sh --delete --zookeeper localhost:2181 --topic your_topic_name Topic your_topic_name is marked for deletion. Note: This will have no impact if delete.topic.enable is not set to true. 

Can I delete a topic?

Jira KAFKA-1397

+96
Jun 18 '14 at 2:37
source share

It seems that the delete command was not officially registered in Kafka 0.8.1.x due to a known bug ( https://issues.apache.org/jira/browse/KAFKA-1397 ).

However, the command was still sent to the code and could be executed as:

 bin/kafka-run-class.sh kafka.admin.DeleteTopicCommand --zookeeper localhost:2181 --topic test 

In the meantime, the error has been fixed, and the uninstall command is now officially available from Kafka 0.8.2.0 as:

 bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic test 
+95
Sep 01 '14 at 10:26
source share

Add the line below to $ {kafka_home} /config/server.properties

 delete.topic.enable=true 

Restart the kafka server with the new configuration:

 ${kafka_home}/bin/kafka-server-start.sh ~/kafka/config/server.properties 

Delete the topics you want:

 ${kafka_home}/bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic daemon12 
+37
Dec 16 '15 at 6:24
source share

Andrea is right. we can do this using the command line.

And we can still program it,

 ZkClient zkClient = new ZkClient("localhost:2181", 10000); zkClient.deleteRecursive(ZkUtils.getTopicPath("test2")); 

In fact, I do not recommend deleting a theme on Kafka 0.8.1.1. I can delete this topic using this method, but if you check the log for zookeeper, delete it.

+10
Sep 05 '14 at 18:08
source share

You can remove a specific kafka theme (example: test ) from the zookeeper shell command ( zookeeper-shell.sh ). Use the command below to delete a topic

 rmr {path of the topic} 

Example:

 rmr /brokers/topics/test 
+4
Nov 16 '15 at 16:30
source share

Steps to remove 1 or more topics in Kafka

To delete themes in kafka, you must enable the delete option on the Kafka server.

 1. Go to {kafka_home}/config/server.properties 2. Uncomment delete.topic.enable=true 

Delete one topic in Kafka enter the following command

kafka-topics.sh --delete --zookeeper localhost: 2181 --topic

To remove more than one topic from kafka

(useful for testing, where I created several topics and had to remove them for different scenarios)

  • Stop Kafka and Zookeeper Server
  • go to the / tmp folder where the logs are stored and manually delete the kafkalogs and zookeeper folders.
  • Restart the zookeeper and kafka server and try to specify the topics,

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

If no topics are specified, all topics are deleted successfully. If topics are indicated, then the deletion was not successful. Repeat the above steps or restart the computer.

+4
Aug 27 '17 at 9:20
source share

In this step, all topics and data will be deleted.

  • Stop Kafka Server and Zookeeper Server
  • Delete the tmp data directories of both services, by default they are C: / tmp / kafka-logs and C: / tmp / zookeeper.
  • then start the zookeeper server and the kafka server
+2
Feb 10 '15 at 10:01
source share

Team:

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

Unfortunately, only notes the topic for deletion.

Removal does not occur.

This creates problems when testing any scripts that prepare the Kafka configuration.

Related streams:

  • Clear Kafka Queue
  • Is there a way to remove all data from a topic or delete a topic before each run?
+2
Apr 28 '16 at 12:37
source share

As mentioned in the doc here

The delete theme option is disabled by default. To enable it, set the server configuration delete.topic.enable = true Currently, Kafka does not support reducing the number of sections for a topic or changing the replication rate.

Make sure delete.topic.enable = true

+1
Feb 17 '15 at 16:46
source share

When adding to the answers above, you must delete the metadata associated with this test in the zookeeper consumer bias path.

bin/zookeeper-shell.sh zookeeperhost:port

rmr /consumers/<sample-consumer-1>/offsets/<deleted-topic>

Otherwise, the lag will be negative in zookeeper-based kafa monitoring tools.

+1
May 12 '16 at 12:47
source share
 bin/kafka-topics.sh –delete –zookeeper localhost:2181 –topic <topic-name> 
+1
Feb 21 '17 at 2:17
source share

If you have problems deleting themes, try deleting the theme using:

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

team. Then, to check the removal process, go to the kafka log directory, which is usually located in /tmp/kafka-logs/ , then delete your_topic_name using the rm -rf your_topic_name .

Remember to control the entire process with the kafka management tool such as the Kafka Tool .

The process mentioned above will delete the threads without restarting the kafka server.

0
Jul 07 '18 at 10:35
source share

Step 1: Make sure you are connected to Zookeeper and Kafka is working

Step 2: To remove the Kafka theme, run Kafka-topic (Mac) or Kafka-topic.sh, if you are using (linux / Mac), add a port and --topic with the name of your theme, and --delete just delete the theme from success.

 # Delete the kafka topic # it will delete the kafka topic kafka-topics --zookeeper 127.0.0.1:2181 --topic name_of_topic --delete # or kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic name_of_topic --delete 
0
Feb 13 '19 at 12:17
source share

First, you run this command to remove your theme:

 $ bin/kafka-topics.sh --delete --bootstrap-server localhost:9092 --topic <topic_name> 

The list of active topics to check delete completely:

 $ bin/kafka-topics.sh --list --bootstrap-server localhost:9092 
0
Jul 03 '19 at 9:09
source share



All Articles