简体   繁体   English

卡夫卡消费群未从单个分区读取

[英]Kafka consumer group not reading from a single partition

I have a kafka topic with 3 partitions. 我有一个带有3个分区的kafka主题。 I have a consumer group consuming from the said topic and I notice that 2 of 3 partitions are being consumed in real-time (lag 0), whereas 1 partition is simply not consumed at all. 我有一个消费群体正在使用该主题,并且我注意到3个分区中的2个正在实时使用(滞后0),而1个分区根本没有使用。

How do I go about diagnosing this issue? 我该如何诊断此问题?

Appreciate inputs/comments. 赞赏输入/评论。

To diagnose the issue you can use kafka-tool. 要诊断问题,您可以使用kafka-tool。

Following command shows partition, current offset, log-end-offset and lag client_id for particular group 以下命令显示特定组的分区,当前偏移量,log-end-offset和滞后client_id

./bin/kafka-consumer-groups.sh --bootstrap-server kafkaAddres:9092 --group yourGroupId --describe

Output will be something like that: 输出将是这样的:

TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                     HOST            CLIENT-ID
input           0          3               4               1               consumer-1-f64504ca-f514-4cef-95fa-1652702d4504 /192.168.160.1  consumer-1
input           1          3               3               0               consumer-1-f64504ca-f514-4cef-95fa-1652702d4504 /192.168.160.1  consumer-1
input           2          3               3               0               consumer-1-f64504ca-f514-4cef-95fa-1652702d4504 /192.168.160.1  consumer-1

Above output shows, that only one consumer is connected and read from all partitions. 上面的输出显示,只有一个使用者连接并从所有分区读取。 At time of checking for partitions 0 lag was 1. 在检查分区时,滞后0为1。

NOTICE : Some of partitions might be empty 注意 :某些分区可能是空的

For your new partitions to reflect, you need to configure the metadata.max.age.ms property for your consumer. 为了反映您的新分区,您需要为使用者配置metadata.max.age.ms属性。

The metadata contains the partitions for a given topic and which brokers are leader for those partitions etc. This is fetched by the consumer when the first poll occurs and is next fetched after the timeout or some error occurs. 元数据包含给定主题的分区,以及哪些代理是这些分区的领导者,等等。当第一次poll发生时,消费者将获取该元数据,而在超时或发生某些错误之后,则将其获取。

By default the timeout is 300000ms = 5 minutes , so until 5 minutes your consumer cannot know the new partitions. 默认情况下,超时为300000ms = 5 minutes ,因此直到5分钟,您的使用者才知道新分区。

Metadata is refreshed either when there is an error or the metadata max age is reached. 当出现错误或达到元数据的最大使用期限时,将刷新元数据。

consumerProperties.put(ConsumerConfig.METADATA_MAX_AGE_CONFIG,"60000");

So try setting it to some thing low. 因此,请尝试将其设置为较低的值。

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

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