[英]Can I auto-reassign partitions on Kafka?
I 'm setting up a Kafka cluster with 3 nodes on Kubernetes.我正在 Kubernetes 上设置一个具有 3 个节点的 Kafka 集群。 If a node crashes, should I auto-reassgin partitions by scripts?
如果节点崩溃,我应该通过脚本自动重新分配分区吗? Thank you very much.
非常感谢。
As @asolanki mentioned, Kafka will automatically failover leaders to brokers that are alive.正如@asolanki 提到的,Kafka 会自动将领导者故障转移到活着的经纪人。 I just wanted to note that this is not called a reassignment - it's called a leader failover .
我只是想指出,这不称为重新分配 - 它称为领导者故障转移。
In Kafka, a partition is assigned to N number of replicas (N=replication factor) .在 Kafka 中,一个分区被分配给 N 个副本(N=复制因子) 。 The in-sync replica set (ISR) is the set of replicas that are in-sync (alive and have the latest data).
同步副本集 (ISR) 是一组同步的副本(活着并拥有最新数据)。 The ISR naturally follows the replica set.
ISR 自然跟随副本集。
A reassignment is when you change the replicas that this partition should be hosted on.重新分配是指更改应托管此分区的副本。 I think an example would make this clear:
我认为一个例子可以说明这一点:
A simple failover :一个简单的故障转移:
1. partition=0 is on brokers (replicas) replicas=[1,2,3], isr=[1,2,3]. Broker 1 is the leader
2. broker 1 fails. Kafka automatically fails over to another broker
3. replicas=[1,2,3], isr=[2,3] (broker 1 is dead)
A simple reassignment :一个简单的重新分配:
1. partition=0 is on brokers (replicas) replicas=[1,2,3], isr=[1,2,3]
2. We reassign partition=0 to replicas=[4,5,6]
3. replicas=[4,5,6], isr=[4,5,6]
Kafka takes care of managing the partitions if replication for a partition is set up correctly.如果分区的复制设置正确,Kafka 会负责管理分区。 Every topic partition in Kafka is replicated n times, where n is the replication factor of the topic.
Kafka 中的每个主题分区都被复制 n 次,其中 n 是主题的复制因子。 So in short if you have set up replication no action is required, pod can go down and back up, the producers and consumers are not affected.
所以简而言之,如果您设置了复制,则不需要任何操作,pod 可以关闭和备份,生产者和消费者不受影响。
For a longer description of how this works look at this有关其工作原理的详细说明,请查看此
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.