Updated on 2025-08-21 GMT+08:00

Deleting a Kafka Topic

This document describes how to delete a topic.

Notes and Constraints

  • Deleting a topic clears the topic data permanently.
  • For an instance with ciphertext access enabled, if allow.everyone.if.no.acl.found is set to false, the topic can be deleted on the client only by the initial user (set in first ciphertext access enablement).

Prerequisite

The instance is in the Running state.

Deleting a Kafka Topic

You can delete a topic on the console or client.

  1. Log in to the Kafka console.
  2. Click in the upper left corner to select the region where your instance is located.
  3. Click the desired instance to go to the instance details page.
  4. In the navigation pane, choose Instance > Topics.
  5. Delete topics using either of the following methods:

    • Select one or more topics and click Delete Topic in the upper left corner.
    • In the row containing the topic you want to delete, choose More > Delete.

  6. In the Delete Topic dialog box, click OK.

    The topic is deleted if it is not displayed in the topic list.

If your Kafka client version is later than 2.2, you can use kafka-topics.sh to delete topics.

  • For a Kafka instance with ciphertext access disabled, run the following command in the /bin directory of the Kafka client:
    ./kafka-topics.sh --bootstrap-server {connection-address} --delete --topic {topic-name}
    Table 1 Topic deletion parameters

    Parameter

    Description

    connection-address

    Connection address of a Kafka instance. To obtain the address, choose Overview > Connection.

    topic-name

    Topic name.

    Example:

    [root@ecs-kafka bin]# ./kafka-topics.sh --bootstrap-server 192.168.xx.xx:9092,192.168.xx.xx:9092,192.168.xx.xx:9092 --delete --topic topic-01
    [root@ecs-kafka bin]#
  • For a Kafka instance with ciphertext access enabled, do as follows:
    1. (Optional) If the SSL certificate has been configured, skip this step and go to 2. Otherwise, do as follows:

      Create the ssl-user-config.properties file in the /config directory of the Kafka client and add the SSL certificate configurations by referring to 3.

    2. Run the following command in the /bin directory of the Kafka client:
      ./kafka-topics.sh --bootstrap-server {connection-address} --delete --topic {topic-name} --command-config ../config/{ssl-user-config.properties}
      Table 2 Topic deletion parameters

      Parameter

      Description

      connection-address

      Connection address of a Kafka instance. To obtain the address, choose Overview > Connection.

      topic-name

      Topic name.

      ssl-user-config.properties

      Configuration file name. This file contains username, password, and SSL certificate information.

      Example:

      [root@ecs-kafka bin]# ./kafka-topics.sh --bootstrap-server 192.168.xx.xx:9093,192.168.xx.xx:9093,192.168.xx.xx:9093 --delete --topic topic-01 --command-config ../config/ssl-user-config.properties
      [root@ecs-kafka bin]#

Related Documents