【帖子】怎么彻底删除kafka的topic,然后重建?
怎么彻底删除kafka的topic,然后重建?
kafka-topics.sh命令查看依然可以查看到topic,应该怎样才能彻底删除topic?
2 个回复
1、从zookeerer删除信息
./bin/kafka-run-class.sh kafka.admin.DeleteTopicCommand --zookeeper 10.0.1.10:2181,10.0.1.11:2181,10.0.1.12:2181 --topic test成功后返回信息:deletion succeeded!
2、利用JPS命令查看kafka和zookeeper进程,kill掉QuorumPeerMain和Kafka进程
3、从kafka的log.dirs目录删除文件,可以看到多个子目录名字如test-0,test-1…test-n(就是你topic的partition个数)
进入到kafka的log.dirs目录,执行
rm –fr test-0……test-n(4) 修改日志目录的recovery-point-offset-checkpoint和replication-offset-checkpoint文件(要小心删除,否则待会kafka不能正常启动起来)
replication-offset-checkpoint格式如下:
0
4(partition总数)
test 0 0
test 3 0
hehe 0 0
hehe 1 0
修改后如下:
0
2(partition总数)
hehe 0 0
hehe 1 0
把含有test行全部去掉,并且把partition总数修改为减去test的partition的剩余数目,同理recovery-point-offset-checkpoint也是这样修改。
完成后就可以正常启动zookeeper和kafka。**从kafka 0.8.2.1**开始可以直接删除topic,步骤如下:
kafka 0.8.1.1之前版本,kafka-topics.sh命令连--delete Delete a topic参数都没有,如下:
# ./kafka-topics.sh --help
Command must include exactly one action: --list, --describe, --create or --alter
Option Description
------ -----------
--alter Alter the configuration for the topic.
--config <name=value> A topic configuration override for the
topic being created or altered.
--create Create a new topic.
--deleteConfig <name> A topic configuration override to be
removed for an existing topic
--describe List details for the given topics.
--help Print usage information.
--list List all available topics.
--partitions <Integer: # of partitions> The number of partitions for the topic
being created or altered (WARNING:
If partitions are increased for a
topic that has a key, the partition
logic or ordering of the messages
will be affected
--replica-assignment A list of manual partition-to-broker
<broker_id_for_part1_replica1 : assignments for the topic being
broker_id_for_part1_replica2 , created or altered.
broker_id_for_part2_replica1 :
broker_id_for_part2_replica2 , ...>
--replication-factor <Integer: The replication factor for each
replication factor> partition in the topic being created.
--topic <topic> The topic to be create, alter or
describe. Can also accept a regular
expression except for --create option
--topics-with-overrides if set when describing topics, only
show topics that have overridden
configs
--unavailable-partitions if set when describing topics, only
show partitions whose leader is not
available
--under-replicated-partitions if set when describing topics, only
show under replicated partitions
--zookeeper <urls> REQUIRED: The connection string for
the zookeeper connection in the form
host:port. Multiple URLS can be
given to allow fail-over.
# **而kafka 0.8.2.1**新增加了这个参数

删除过程:
1、在kafka配置文件中添加删除参数
delete.topic.enable=true2、利用命令删除需要删除的topic
bin/kafka-topics.sh --zookeeper zk_host:port/chroot --delete --topic my_topic_namehttp://kafka.apache.org/documentation.html#gettingStarted如下:

【帖子】怎么彻底删除kafka的topic,然后重建?的更多相关文章
- 删除kafka的topic及kafka基本命令
kafka的topic默认是不允许被删除的,删除后在topic后会出现”marked for deletion”字样,实际并未删除,现在创建同样的topic会提示topic已经存在. 解决办法: se ...
- Kafka学习笔记之如何永久删除Kafka的Topic
0x00 问题描述 使用kafka-topics --delete命令删除topic时并没有真正的删除,而是把topic标记为:“marked for deletion”,导致重新创建相同名称的Top ...
- 删除Kafka的topic
刚接触Kafka,开始认为删除一个topic只是运行一下Kafka-topic.sh的delete命令就行了,但是,事实却不是这样,会出现两种情况:(1) 如果topic没有使用过即没有传输过消息,可 ...
- 如何删除Kafka的Topic
在server.properties文件中添加配置:delete.topic.enable=true 创建kafka主题: kafka-topics.sh --create --zookeeper 1 ...
- 删除Kafka中topic
步骤: 1.编辑Kafka启动时加载的配置文件server.properties,添加一行:delete.topic.enable=true 2.重启Zookeeper和Kafka 3.执行: ./b ...
- 彻底删除Kafka中的topic
1.删除kafka存储目录(server.properties文件log.dirs配置,默认为"/tmp/kafka-logs")相关topic目录 2.Kafka 删除topic ...
- [Spark][kafka]kafka 的topic 创建和删除试验
kafka 的topic 创建和删除试验 zookeeper和kafka 的安装,参考: http://www.cnblogs.com/caoguo/p/5958608.html 参考上述URL后,在 ...
- 删除kafka topic
1.因为项目原因,kakfa通道中经常造成数据阻塞,导致kafka通道中数据量过大,因此我需要将kakfa通道中数据清除(个人项目原因,一直使用一个消费者,只要保证当前消费者不在消费之前很久的数据就可 ...
- 手动删除Kafka Topic
一.删除Kafka topic 运行./bin/kafka-topics --delete --zookeeper [zookeeper server] --topic [topic name]: ...
随机推荐
- python 冒泡排序
冒泡排序: 相邻的两个数字先进行比较,也就是li[0]和li[1]进行比较,如果不是大于的关系,就继续依次进行li[1]和li[2]比较,进行交换然后每一次扫描得到的新列表如下: li = [11,2 ...
- bzoj2959: 长跑
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...
- sersync2 安装,配置
介绍 rsync rsync,remote synchronize顾名思意就知道它是一款实现远程同步功能的软件,它在同步文件的同时,可以保持原来文件的权限.时间.软硬链接等附加信息.rsync是用 “ ...
- centos虚拟机克隆
vmware vsphere平台上克隆centos6 一.删掉/etc/udev/rules.d/70-persistent-net.rules文件 reboot 二.vim ifcfg-eth0 删 ...
- EF-CodeFirst-3搞事
本文学习旺杰兄的 CodeFirst 系列教程而写.尽量摆脱之前的影子写出自己的理解 表间关系.级联删除 简单玩法已经走通了,但是我就是想搞点事出来.今天来搞搞表间关系和级联删除 表间关系 毫无疑问在 ...
- Unity连Photon服务器入门详解
Photon是目前比较好用的游戏服务器.目前网上对于Photon的服务器讲解比较少,最近也对Photon做了初步的了解,做一个极其详细的入门. 首先就是得下载Photon咯 https://www.p ...
- iOS - Availability.h
>for 'dispatch' application inner to begin note `#include <Availability.h>` These macros ar ...
- Linux 问题汇总
centos主机发现大量的TIME_WAIT 解决方法: vim /etc/sysctl.conf #编辑文件,加入以下内容: net.ipv4.tcp_syncookies = 1 net.ipv ...
- CookContainer 序列化保存
using System;using System.Collections;using System.Globalization;using System.IO;using System.Net;us ...
- sed,grep,awk命令常用法
查看当天nginx访问日志中2016:03:25到2016:05点passport.mingxiao.com域名访问量最多的url,可以查看网站是否被刷. 法一: sed -n '/2016:03:2 ...