[英]Kafka - This server is not the leader for that topic-partition
I have two broker kafka 0.10.2.0 cluster.Replication factor is 2. I am running 1.0.0 kafka stream application against this Kafka. 我有两个经纪人kafka 0.10.2.0 cluster.Replication factor是2.我正在对这个Kafka运行1.0.0 kafka流应用程序。 In my kafka stream application, producer config has
retries = 10 and retry.backoff.ms = 100
在我的kafka流应用程序中,producer config的
retries = 10 and retry.backoff.ms = 100
After running few minutes, I observed following logs in Kakfa server.log. 运行几分钟后,我在Kakfa server.log中观察了以下日志。 Due to this Kafka stream application is throwing 'NOT_LEADER_FOR_PARTITION' exception.
由于此Kafka流应用程序正在抛出'NOT_LEADER_FOR_PARTITION'异常。
What may be the possible reason? 可能的原因是什么? Please help me.
请帮我。
[2017-12-12 10:26:02,583] ERROR [ReplicaFetcherThread-0-1], Error for partition [__consumer_offsets,22] to broker 1:org.apache.kafka.common.errors.NotLeaderForPartitionException: This server is not the leader for that topic-partition. (kafka.server.ReplicaFetcherThread)
Each topic is served by one or multiple Brokers - one is leader and the remaining brokers are followers. 每个主题由一个或多个经纪人提供 - 一个是领导者,其余经纪人是追随者。
A producer needs to send new messages to the leader Broker which internally replicate the data to all followers. 生产者需要向领导者Broker发送新消息,Broker在内部将数据复制到所有关注者。
I assume, that your producer client does not connect to the correct Broker, its connect to a follower instead of the leader, and this follower rejects your send request. 我假设,您的生产者客户端没有连接到正确的Broker,它连接到跟随者而不是领导者,并且此关注者拒绝您的发送请求。
Try to run ./kafka-topics.sh --zookeeper localhost:2181 --topic your_topic --describe
尝试运行
./kafka-topics.sh --zookeeper localhost:2181 --topic your_topic --describe
Topic:your_topic PartitionCount:3 ReplicationFactor:1 Configs:retention.ms=14400000
Topic: your_topic Partition: 0 Leader: 2 Replicas: 2 Isr: 2
Topic: your_topic Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: your_topic Partition: 2 Leader: 1 Replicas: 1 Isr: 1
In this example you can see that your_topic
have 3 partitions meaning all 3 brokers are leaders of that topic each on different partition, st broker 2
is leader on partition 0
and broker 0
and broker 1
are followers on partition 0
. 在此示例中,您可以看到
your_topic
有3个分区,这意味着所有3个代理都是该主题的领导者,每个broker 2
位于不同的分区上,st broker 2
是partition 0
上的领导者, broker 0
和broker 1
是partition 0
上的跟随者。
Try setting these properties and see if it helps resolve the issue: 尝试设置这些属性,看看它是否有助于解决问题:
props.put(ProducerConfig.RETRIES_CONFIG, 10); //increase to 10 from default of 0
props.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG,
Integer.toString(Integer.MAX_VALUE)); // increase to infinity from default of 300 s
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.