kafka平衡leader

半兽人 发表于: 2015-03-10   最后更新时间: 2016-04-09  
  •   40 订阅,1979 游览

平衡leader


Whenever a broker stops or crashes leadership for that broker's partitions transfers to other replicas. This means that by default when the broker is restarted it will only be a follower for all its partitions, meaning it will not be used for client reads and writes.

每当一个broker停止或崩溃,broker转移到其他的副本。在默认情况下,当这个broker重新启动,它也只会跟随它的所有分区。并不会用于客户端的读和写。


To avoid this imbalance, Kafka has a notion of preferred replicas. If the list of replicas for a partition is 1,5,9 then node 1 is preferred as the leader to either node 5 or 9 because it is earlier in the replica list. You can have the Kafka cluster try to restore leadership to the restored replicas by running the command:
为了避免这种不平衡,kafka有个首先副本的概念,如果一个分区的副本列表是1,5,9。节点1优先作为领导者,或者节点5或9。是因为节点1早先在列表中。你可以在kafka集群中运行这个命令来恢复leader和副本。

 > bin/kafka-preferred-replica-election.sh --zookeeper zk_host:port/chroot


Since running this command can be tedious you can also configure Kafka to do this automatically by setting the following configuration:

手动运行很无趣,你可以通过这个配置设置为自动执行:
    auto.leader.rebalance.enable=true






发表于: 1年前   最后更新时间: 9月前   游览量:1979
上一条: 优雅的关闭kafka
下一条: kafka镜像集群之间的数据
评论…

  • 评论…
    • in this conversation
      提问