简体   繁体   English

Apache Kafka:如何找出主题的消费者群体?

[英]Apache Kafka: How to find out consumer group of a topic?

I am working on Kafka with Spark streaming in Scala.我正在使用 Scala 中的 Spark 流处理 Kafka。 There are multiple topics from which I need to fetch messages.我需要从多个主题中获取消息。 For that, I need to input consumer group of each topic.为此,我需要输入每个主题的消费者组。

I have tried following command:我尝试过以下命令:

bin/kafka-consumer-groups.sh --zookeeper localhost:2181 --describe --group group_name

For this, I need to mention consumer group and check whether my topic falls under this group.为此,我需要提及消费者组并检查我的主题是否属于该组。 But I don't know the consumer group value for some topics.但我不知道某些主题的消费群体价值。

So, is there any command or programmatic way of finding consumer group for a given topic?那么,是否有任何命令或编程方式来查找给定主题的消费者组?

Any help on this would be greatly appreciated.对此的任何帮助将不胜感激。 Thank you谢谢

You can read data from various topics by specifying the topics.您可以通过指定主题从各种主题中读取数据。 You can simply create a Map of topics.您可以简单地创建一个主题地图。 Refer to the below link请参考以下链接

https://www.tutorialspoint.com/apache_kafka/apache_kafka_consumer_group_example.htm https://www.tutorialspoint.com/apache_kafka/apache_kafka_consumer_group_example.htm

There is no Command/API provided by kafka to list consumer groups consuming from a specified topic. kafka 没有提供命令/API 来列出从指定主题消费的消费者组。 Instead you can use a tool developed by yahoo to manage kafka clusters : Yahoo Kafka Manager .相反,您可以使用 yahoo 开发的工具来管理 kafka 集群: Yahoo Kafka Manager After installing this software and pointing yahoo kafka manager to your kafka cluster, you can view consumer groups consuming from a specified topic.安装完这个软件,将yahoo kafka manager 指向你的kafka集群后,就可以查看从指定topic消费的consumer group了。

for i in `kafka-consumer-groups --list --bootstrap-server localhost:9092`; do echo $i; (kafka-consumer-groups --describe --bootstrap-server localhost:9092 --group $i 2>&1| grep mytopic); done

这需要一些时间,因为它会检查所有主题,但会告诉哪些消费者群体使用该主题。

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

相关问题 如何找到消费者组从kafka主题消费数据的开始时间 - How to Find Starting time of consuming data from a kafka topic by the consumer group 如何从Java代码中删除Kafka主题的使用者组? - How to delete a consumer group of a Kafka Topic from java code? 如何找到哪个消费者分配给kafka中主题的哪个分区? - How to find which consumer is assigned to which partition of a topic in kafka? 如何在kafka消费者中按内容设置主题? - How to set topic by content in kafka consumer? Apache Kafka 中的“简单消费者组”是什么? - What is 'Simple Consumer Group' in Apache Kafka? 如果某个消费者组订阅了多个主题分区,那么kafka如何确定它将首先读取的内容? - If a consumer group is subscribed to multiple topic partitions how does kafka decide which it will read first? 卡夫卡消费者的多个话题 - Kafka consumer for multiple topic 当我使用 akka 流在现有消费者组中创建新消费者时,如何寻求结束 kafka 主题? - How do I seek to end of a kafka topic when I am creating a new consumer in an existing consumer group with akka streams? 在Kafka -Java中为同一主题创建多个使用者组 - Create Multiple Consumer Group for same topic in Kafka -Java Apache Kafka:3个分区,消费组有3个消费者,每个消费者都应该是多线程的 - Apache Kafka: 3 partitions, 3 consumers in the consumer group, each consumer should be multithreaded
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM