Don't think it is supported yet. Take a look at this JIRA tracking Delete Topic. For delete manually

  1. Shutdown the cluster
  2. Clean kafka log dir (specified by the log.dir attribute in kafka config file ) as well the zookeeper data
  3. Restart the cluster

For any given topic what you can do is

  1. Stop kafka
  2. Clean kafka log specific to partition, kafka stores its log file in a format of "logDir/topic-partition" so for a topic named "MyTopic" the log for partition id 0 will be stored in /tmp/kafka-logs/MyTopic-0 where /tmp/kafka-logs is specified by the log.dir attribute
  3. Restart kafka

This is NOT a good and recommended approach but it should work. In the Kafka broker config file the log.retention.hours.per.topic attribute is used to define The number of hours to keep a log file before deleting it for some specific topic

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

命令删除后数据文件依然存在,上边的方法是根本删除

create kafka-delete-topic.sh file

#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
base_dir=$(dirname $0)
export KAFKA_OPTS="-Xmx512M -server -Dcom.sun.management.jmxremote -Dlog4j.configuration=file:$base_dir/kafka-console-consumer-log4j.properties"
$base_dir/kafka-run-class.sh kafka.admin.DeleteTopicCommand $@

https://issues.apache.org/jira/browse/KAFKA-330

http://stackoverflow.com/questions/17730905/is-there-a-way-to-delete-all-the-data-from-a-topic-or-delete-the-topic-before-ev

kafka delete topic 问题跟进

https://issues.apache.org/jira/browse/KAFKA-330

kafka delete topic的更多相关文章

  1. 【帖子】怎么彻底删除kafka的topic,然后重建?

    怎么彻底删除kafka的topic,然后重建? 网上都说用kafka-run-class.shkafka.admin.DeleteTopicCommand 命令删除topic,但是并没有成功,用kaf ...

  2. kafka删除topic的方法及我在kafka上边的一些经验

    我在本地做kafka的producer调试,每隔一段时间后,所使用的topic管道就会堆积数据,而且我这边使用的是  kafka   bin 下的consumer命令单独消费的,每次都是  --fro ...

  3. 删除kafka的topic及kafka基本命令

    kafka的topic默认是不允许被删除的,删除后在topic后会出现”marked for deletion”字样,实际并未删除,现在创建同样的topic会提示topic已经存在. 解决办法: se ...

  4. 如何删除Kafka的Topic

    在server.properties文件中添加配置:delete.topic.enable=true 创建kafka主题: kafka-topics.sh --create --zookeeper 1 ...

  5. kafka删除topic详解

    1.删除topic命令 bin/kafka-topics.sh --delete --zookeeper 192.168.242.131:2181 --topic aaa 注:此命令如果要生效,还需在 ...

  6. [Spark][kafka]kafka 的topic 创建和删除试验

    kafka 的topic 创建和删除试验 zookeeper和kafka 的安装,参考: http://www.cnblogs.com/caoguo/p/5958608.html 参考上述URL后,在 ...

  7. 052 kafka对topic的增删改查操作

    一:create 1.开始使用命令 2.创建 bin/kafka-topics.sh --create --topic beifeng --zookeeper linux-hadoop01.ibeif ...

  8. kafka删除topic数据

    一.概述 生产环境中,有一个topic的数据量非常大.这些数据不是非常重要,需要定期清理. 要求:默认保持24小时,某些topic 需要保留2小时或者6小时 二.清除方式 主要有3个: 1. 基于时间 ...

  9. kafka 清除topic数据脚本

    原 kafka 清除topic数据脚本 2018年07月25日 16:57:13 pete1223 阅读数:1028     #!/bin/sh       param=$1   echo " ...

随机推荐

  1. 采用LinkedList来模拟栈数据结构的集合--先进后出

    三.用LinkedList来模拟栈数据结构的集合 /* * 自定义一个数据结构为LinkedList的集合类*/public class MyCollection_LinkedList { publi ...

  2. 华为S5300系列升级固件S5300SI-V200R001C00SPC300.cc

    附带web,V200版本的第一个固件. 附件: 链接:https://pan.baidu.com/s/1QyXIIVho9AkhxUFYJYAkcw  密码:gaxm

  3. PostgreSQL SystemTap on Linux 转

    PostgreSQL 支持动态跟踪, 可以通过dtrace或者systemtap工具统计相关探针的信息. 安装systemtap yum install systemtap kernel-debugi ...

  4. mysql 审计插件编写

    http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=1864367&page=1#pid13527550 http://blog ...

  5. svn如何提取文件更新列表

    eclipse svn插件site-1.10.1 Slik-Subversion-1.8.0-x64.msi  ---可以使用svn命令,如svn status 显示修改过的本地文件,如下示例: I: ...

  6. blurImage做图片模糊处理报错free(): invalid next size

    $image = new Imagick($url); $image->blurImage($x, $y); 调用blurImage($x, $y)函数报错: 原因是:原来的图片是CMYK的是印 ...

  7. shader 4 杂 一些和函数名词、数据结构

    Normal:  法线 Normao mapping: 法线贴图 Lighting mapping: 光照贴图 Bump mapping:     凹凸贴图:模拟粗糙外表面的技术. FX-Water ...

  8. Javascript 面向对象编程(一):封装(转载)

    Javascript是一种基于对象(object-based)的语言,你遇到的所有东西几乎都是对象.但是,它又不是一种真正的面向对象编程(OOP)语言,因为它的语法中没有class(类). 那么,如果 ...

  9. 关于linux系统端口查看和占用的解决方案

    原文:http://www.2cto.com/os/201411/355959.html 一直以来,在处理linux服务器的过程中,经常会遇到一个问题,有时候kill掉进程之后,端口被占用,新的进程一 ...

  10. utils/CCArmatureDefine

    #ifndef __CCARMATUREDEFINE_H__ #define __CCARMATUREDEFINE_H__ //#define _USRDLL 1 #include "coc ...