集群环境下的kafka监控
Kafka monitoring in cluster environment
我有一个 kafka 集群(3 台机器,每台机器上有 1 个动物园管理员和 1 个代理 运行)
我正在使用 kafka_exporter 来监控消费者滞后指标,它在正常情况下工作正常。
但是,当我杀死 1 个代理时,Prometheus 无法从 http://machine1:9308/metric(kafka_exporter 指标端点)获取指标,因为获取数据需要很长时间 (1,5m),因此会超时。
现在,如果我重新启动 kafka_exporter 我会看到一些错误:
Cannot get leader of topic __consumer_offsets partition 20: kafka server: In the middle of a leadership election, there is currently no leader for this partition and hence it is unavailable for writes
当我运行命令:kafka-topics.bat --describe --zookeeper machine1:2181,machine2:2181,machine3:2181 --topic __consumer_offsets
结果是:
Topic:__consumer_offsets PartitionCount:50 ReplicationFactor:1 Configs:compression.type=producer,cleanup.policy=compact,segment.bytes=104857600
Topic: __consumer_offsets Partition: 0 Leader: -1 Replicas: 1 Isr: 1
Topic: __consumer_offsets Partition: 1 Leader: 2 Replicas: 2 Isr: 2
Topic: __consumer_offsets Partition: 49 Leader: 2 Replicas: 2 Isr: 2
这是配置错误吗?在这种情况下,我怎样才能让消费者滞后? "Leader: -1" 是一个错误?如果我永远关闭机器 1,它仍然可以正常工作吗?
leader 为 -1 意味着集群中没有其他 broker 具有该分区的数据副本。
您的问题是您的主题 __consumer_offsets 的复制因子为 1,这意味着只有一个代理托管主题中任何分区的数据。如果您丢失任何一个代理,代理上的所有分区都会变得不可用,从而导致主题变得不可用。因此,您的 kafka_exporter 将无法阅读该主题。
如果您想在代理人损失时继续导出消费者抵消,解决此问题的方法是重新配置主题 __consumer_offsets 使其复制因子大于 1。
建议配置 - 复制因子 - 3,min.insync.replicas - 2。
我有一个 kafka 集群(3 台机器,每台机器上有 1 个动物园管理员和 1 个代理 运行) 我正在使用 kafka_exporter 来监控消费者滞后指标,它在正常情况下工作正常。 但是,当我杀死 1 个代理时,Prometheus 无法从 http://machine1:9308/metric(kafka_exporter 指标端点)获取指标,因为获取数据需要很长时间 (1,5m),因此会超时。 现在,如果我重新启动 kafka_exporter 我会看到一些错误:
Cannot get leader of topic __consumer_offsets partition 20: kafka server: In the middle of a leadership election, there is currently no leader for this partition and hence it is unavailable for writes
当我运行命令:kafka-topics.bat --describe --zookeeper machine1:2181,machine2:2181,machine3:2181 --topic __consumer_offsets 结果是:
Topic:__consumer_offsets PartitionCount:50 ReplicationFactor:1 Configs:compression.type=producer,cleanup.policy=compact,segment.bytes=104857600
Topic: __consumer_offsets Partition: 0 Leader: -1 Replicas: 1 Isr: 1
Topic: __consumer_offsets Partition: 1 Leader: 2 Replicas: 2 Isr: 2
Topic: __consumer_offsets Partition: 49 Leader: 2 Replicas: 2 Isr: 2
这是配置错误吗?在这种情况下,我怎样才能让消费者滞后? "Leader: -1" 是一个错误?如果我永远关闭机器 1,它仍然可以正常工作吗?
leader 为 -1 意味着集群中没有其他 broker 具有该分区的数据副本。
您的问题是您的主题 __consumer_offsets 的复制因子为 1,这意味着只有一个代理托管主题中任何分区的数据。如果您丢失任何一个代理,代理上的所有分区都会变得不可用,从而导致主题变得不可用。因此,您的 kafka_exporter 将无法阅读该主题。
如果您想在代理人损失时继续导出消费者抵消,解决此问题的方法是重新配置主题 __consumer_offsets 使其复制因子大于 1。
建议配置 - 复制因子 - 3,min.insync.replicas - 2。