Home > Java > javaTutorial > body text

A concise and easy-to-understand guide to deleting topics in Kafka

WBOY
Release: 2024-02-01 08:49:05
Original
611 people have browsed it

A concise and easy-to-understand guide to deleting topics in Kafka

Kafka Delete Topic Command Tutorial

Prerequisites

  • The Kafka cluster has been installed and running.
  • User with administrator rights.

Delete Topic command

kafka-topics --delete --topic topic-name
Copy after login

Parameters

  • --delete: Specify the Topic to be deleted.
  • --topic: The name of the Topic to be deleted.

Example

kafka-topics --delete --topic my-topic
Copy after login

Note

  • Before deleting a Topic, please ensure that there is no uncommitted data in the Topic. If there is uncommitted data, deleting the topic may result in data loss.
  • After deleting a Topic, the Topic cannot be recovered. Therefore, please think carefully before deleting a topic.

FAQ

Q: How to delete a Topic with multiple partitions?

Answer: Use the --partitions parameter to specify the number of partitions to be deleted. For example, to delete a Topic with 3 partitions, you can use the following command:

kafka-topics --delete --topic my-topic --partitions 3
Copy after login

Q: How to delete a Topic with multiple replicas?

Answer: Use the --replicas parameter to specify the number of replicas to delete. For example, to delete a Topic with 2 replicas, you can use the following command:

kafka-topics --delete --topic my-topic --replicas 2
Copy after login

Q: How to delete a Topic with compression?

Answer: Use the --compression-type parameter to specify the compression type to be deleted. For example, to delete a Topic with GZIP compression, you can use the following command:

kafka-topics --delete --topic my-topic --compression-type gzip
Copy after login

Q: How to delete a Topic with a retention policy?

Answer: Use the --retention-ms parameter to specify the retention time to be deleted. For example, to delete a Topic with a retention time of 1 day, you can use the following command:

kafka-topics --delete --topic my-topic --retention-ms 86400000
Copy after login

Q: How to delete a Topic with a cleanup policy?

Answer: Use the --cleanup-policy parameter to specify the cleanup policy to be deleted. For example, to delete a Topic with a deletion policy, you can use the following command:

kafka-topics --delete --topic my-topic --cleanup-policy delete
Copy after login

The above is the detailed content of A concise and easy-to-understand guide to deleting topics in Kafka. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template