gpt4 book ai didi

apache-kafka - kafka如何删除没有领导者的主题

转载 作者:行者123 更新时间:2023-12-04 02:11:13 25 4
gpt4 key购买 nike

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

reproduce:

  1. Create a topic with ReplicationFactor=1
  2. Shutdown the only one broker host
  3. Use kafka-topic --delete to delete the topic
  4. Delete process will never end (I waited for more than 6 month, and it starting to get hurt)

主题描述

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

关于apache-kafka - kafka如何删除没有领导者的主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38139445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com