繁体   English   中英

kafka如何删除没有领导者的话题

[英]kafka how to delete topic with no leader

没有领导者,我无法删除/重新分配/对主题进行任何更改

复制:

  1. 使用ReplicationFactor = 1创建一个主题
  2. 关闭唯一的经纪人主机
  3. 使用kafka-topic --delete删除主题
  4. 删除过程将永远不会结束(我等待了6个月以上,开始受到伤害)

描述主题

Topic:topic_73  PartitionCount:1    ReplicationFactor:1
Configs:unclean.leader.election.enable=true
Topic: topic_73 Partition: 0    Leader: -1  Replicas: 755   Isr:

经纪人755永不回头,我该如何解决?

您可以尝试使用此脚本清除Zookeeper中的元数据,然后直接删除kafka日志。

./clear.sh /path-to-kafka-logs sampletopic /path-to-kafka-bin-dir

clear.sh的内容如下:

#!/bin/bash
# this script is for the situation that leader is set to -1 and there is no ISR
ZK_HOST=`hostname`
ROOT_DIR=$1
TOPIC=$2
KAFKA_LOG_DIR=$3

# make sure kafka service is stopped while running this
rm -rf ${KAFKA_LOG_DIR}/${TOPIC}*
${ROOT_DIR}/kafka/bin/kafka-topics.sh --zookeeper ${ZK_HOST}:2181 --topic ${TOPIC} --delete
${ROOT_DIR}/kafka/bin/zookeeper-shell.sh ${ZK_HOST}:2181 rmr /brokers/topics/${TOPIC}
${ROOT_DIR}/kafka/bin/zookeeper-shell.sh ${ZK_HOST}:2181 rmr /admin/delete_topics/${TOPIC}

使用前请确保chmod +x clear.sh

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM