I can't delete / reassign / make any change to topics without leader
reproduce:
- Create a topic with ReplicationFactor=1
- Shutdown the only one broker host
- Use kafka-topic --delete to delete the topic
- Delete process will never end (I waited for more than 6 month, and it starting to get hurt)
describe of topic
Topic:topic_73 PartitionCount:1 ReplicationFactor:1
Configs:unclean.leader.election.enable=true
Topic: topic_73 Partition: 0 Leader: -1 Replicas: 755 Isr:
broker 755 can never gone back how can i fix this?
You can try this script to clear metadata from zookeeper and directly delete the kafka logs.
./clear.sh /path-to-kafka-logs sampletopic /path-to-kafka-bin-dir
clear.sh content is as below:
#!/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}
make sure chmod +x clear.sh
before using it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.