前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >kafka leader 服务器均衡。

kafka leader 服务器均衡。

作者头像
sanmutongzi
发布2020-03-04 14:48:56
5980
发布2020-03-04 14:48:56
举报
文章被收录于专栏:stream processstream process

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服务停掉或者崩溃后,位于本机上的partition的leader身份会赋予到其他的副本上面。这意味着默认情况下当一台broker服务重启后它上面的所有的partition都是follower身份,不会用于服务外部客户端的读写操作(所以会造成不均衡)

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发明了一个prefered replicas的概念。如果某一个副本的副本分布id为1,5,9,那么相比5和9的节点,节点1的由于在副本队列里更靠前就成为了preferer的partition。可以在集群上运行下列命令将各副本的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:

由于手动运行这个命令会很枯燥,也可以在配置文件里设置如下属性打开kafka自动balance选举的功能

auto.leader.rebalance.enable=true

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-02-25 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档