集群中的代理宕机后会发生什么? [英] what happens after a broker is down in a cluster?

查看:29
本文介绍了集群中的代理宕机后会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设一个 broker 长时间宕机,那么这个 broker 所包含的追随者和领导者会发生什么?

Suppose a broker is down for long time, now what happens to the followers and leaders that this broker was containing?

  • 如果代理包含一个领导者,并且选择一个同步副本作为领导者,它是否会创建另一个同步副本(如果我们有特定的复制因子)?

  • if broker was containing a leader and one of in-sync replica is chosen as leader, does it create another in-sync replica(in case we have specific replication factor)?

如果broker包含一个follower,它会在集群的其他地方创建另一个follower吗?

if broker was containing a follower, does it create another follower elsewhere in cluster?

现在假设 broker 在很长一段时间后醒来,现在领导者和追随者是否会在它倒下时恢复原状?

now suppose broker awakens after long time, now do leaders and followers are restored as it left when it went down?

推荐答案

当代理关闭时会发生什么取决于您的配置.这主要取决于这些配置设置:

What happens when a broker is down depends on your configuration. It mostly depends on these configuration settings:

  • min.insync.replicas
  • default.replication.factor
  • unclean.leader.election.enable

当代理宕机时,Kafka 不会创建新的副本.

Kafka does not create a new replica when a broker goes down.

如果离线代理是领导者,则从同步的副本中选出新的领导者.如果没有副本同步,它只会在 unclean.leader.election.enable 为 true 时选出一个不同步的副本,否则分区将处于离线状态.

If the offline broker was a leader, a new leader is elected from the replicas that are in-sync. If no replicas are in-sync it will only elect an out of sync replica if unclean.leader.election.enable is true, otherwise the partition will be offline.

如果离线broker是follower,它会被leader标记为不同步.

If the offline broker was a follower, it will be marked a out of sync by the leader.

当重新启动代理时,它会尝试恢复同步.完成后,它是保持跟随者还是成为领导者取决于它是否是首选副本.

When restarting the broker, it will try to get back in sync. Once done, whether it stays a follower or becomes the leader depends if it is the prefered replica.

最后,如果您知道某个代理将长时间离线并且仍然需要副本,您可以使用重新分配工具 kafka-reassign-partitions.sh 将分区移动到在线代理.

Finally if you know a broker will be offline for a long time and still require a replica, you can use the reassignment tool kafka-reassign-partitions.sh to move partitions to online brokers.

这篇关于集群中的代理宕机后会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆