![](https://img.haomeiwen.com/i12979420/f9fa40ed66647f78.png)
![](https://img.haomeiwen.com/i12979420/0bef2ae40f43050a.png)
![](https://img.haomeiwen.com/i12979420/d5f43c4cab213fd3.png)
$ cat check_kafka.sh
#!/bin/bash
kafka_host="xx.xx.xx.xx"
kafka_port="9092"
kafka_zookeeper_port="2189"
kafka_bin_path="/path/to/kafka/bin"
# list 出所有topic并describe每个topic详情
topics=`${kafka_bin_path}/kafka-topics.sh --zookeeper ${kafka_host}:${kafka_zookeeper_port} --list`
for topic in ${topics};
do
echo "######################################################################"
echo ""
${kafka_bin_path}/kafka-topics.sh --zookeeper ${kafka_host}:${kafka_zookeeper_port} --topic ${topic} --describe
done
# list 出所有consumer_group并describe每个consumer_group详情
consumer_groups=`${kafka_bin_path}/kafka-consumer-groups.sh --bootstrap-server ${kafka_host}:${kafka_port} --list`
for consumer_group in ${consumer_groups};
do
echo "########################################################################"
${kafka_bin_path}/kafka-consumer-groups.sh --bootstrap-server ${kafka_host}:${kafka_port} --group ${consumer_group} --describe
done
# 修改 topic的partition,根据业务决定
partition_num="9"
${kafka_bin_path}/kafka-topics.sh --zookeeper ${kafka_host}:${kafka_zookeeper_port} --topic ${topic} --alter --partitions ${partition_num}
网友评论