Updated on 2024-05-30 GMT+08:00

Deleting a Kafka Consumer Group

You can delete a consumer group using either of the following methods:

  • Method 1: Delete a consumer group on the console.
  • Method 2: Use Kafka CLI to delete a consumer group. (Ensure that the Kafka instance version is the same as the CLI version.)

Prerequisites

The status of the consumer group to be deleted is EMPTY.

Constraints

  • If auto.create.groups.enable is set to true, the consumer group status is EMPTY, and no offset has been submitted, the system automatically deletes the consumer group 10 minutes later.
  • If auto.create.groups.enable is set to false, the system does not automatically delete consumer groups. You can manually delete them.

Method 1: Deleting a Consumer Group on the Console

  1. Log in to the console.
  2. Click in the upper left corner to select a region.

    Select the region where your Kafka instance is located.

  3. Click and choose Application > Distributed Message Service for Kafka to open the console of DMS for Kafka.
  4. Click the desired Kafka instance to view the instance details.
  5. In the navigation pane, choose the Consumer Groups tab.
  6. Delete consumer groups using either of the following methods:

    • Select one or more consumer groups and click Delete Consumer Group above the consumer group list.
    • In the row containing the consumer group you want to delete, click Delete.

    A consumer group can be deleted only when its status is EMPTY.

    Consumer group statuses include:

    • DEAD: The consumer group has no member or metadata.
    • EMPTY: The consumer group has metadata but has no member.
    • PREPARING_REBALANCE: The consumer group is to be rebalanced.
    • COMPLETING_REBALANCE: All members have joined the consumer group.
    • STABLE: Members in the consumer group can consume messages normally.

  7. In the displayed Delete Consumer Group dialog box, click OK.

Method 2: Using the CLI to Delete a Consumer Group

The following uses Linux as an example.

  1. Download Kafka CLI v1.1.0, v2.3.0, or v2.7.2. Ensure that the Kafka instance and the CLI are of the same version.
  2. Use the CLI to connect to the Kafka instance. For details, see Connecting to Kafka Using the Client (SASL Disabled) or Connecting to Kafka Using the Client (SASL Enabled).
  3. In the /{directory where the CLI is located}/kafka_{version}/bin/ directory, run the following command to delete a consumer group:

    ./kafka-consumer-groups.sh --bootstrap-server {Kafka instance connection address} --delete --group {consumer group name}

    [root@zk-server-1 bin]# ./kafka-consumer-groups.sh --bootstrap-server 192.168.1.245:9091,192.168.1.86:9091,192.168.1.128:9091 --delete --group bbbb
    Note: This will not show information about old Zookeeper-based consumers.
    Deletion of requested consumer groups ('bbbb') was successful.

    If SASL is enabled for the Kafka instance, the --command-config {consumer.properties file with SASL authentication} parameter must be added to the preceding commands. For details about the consumer.properties file, see Connecting to Kafka Using the Client (SASL Enabled).