`
邢邢色色
  • 浏览: 226087 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Kafka学习之Replication tools之Reassign Partitions Tool

阅读更多

 

原文链接:https://cwiki.apache.org/confluence/display/KAFKA/Replication+tools#Replicationtools-6.ReassignPartitionsTool

此工具能做啥?

此工具的作用跟Referred Replica Leader Election工具类似,都是为了平衡集群的负载。但工具不仅为某一个partition从assigned replica中选举一个新的leader,还改变partition的assigned replica,回忆一下,follower需要从leader上fetch数据为了保持同步,因此有时仅仅平衡leadershipi的负载是不够的(还需要考虑follower的负载)。下面是此工具工作的步骤:

 

1,此工具更新ZK的路径"/admin/reassign_partitions",写入一个topic的partition列表和一个new assigned replica列表(如果设置了json文件了的话)。


2,controller监听ZK上的路径。当数据update时被触发,controller从ZK读取更新的topic partition的列表和它们的assigned replicas。


3,对于每一个topic的partition,controller做如下的事情:
3.1. 开始一个新的replicas,由RAR - AR(RAR中存在,AR中不存在的replica)组成(RAR = Reassigned Replicas, AR = original list of Assigned Replicas)。
3.2. 在新的replica跟leader同步之前保持等待状态。
3.3. 如果leader不在RAR中,从RAR选举一个新的leader。
3.4 4. 停止老的replicas,由AR - RAR(AR中存在,RAR中不存在的replica)组成。
3.5. 写入新的AR。
3.6. 从/admin/reassign_partitions删除partition。

 

注意此工具只更新zk并退出,controller异步为partitions reassign replicas。

此工具现在只在0.8分支中提供。

 

如何使用?

警告:此工具在0.8的beta版本释出,并有一些bug,在0.8.1版本中是稳定的。

bin/kafka-reassign-partitions.sh
 
Option                                  Description
------                                  -----------
--broker-list <brokerlist>              The list of brokers to which the
                                          partitions need to be reassigned in
                                          the form "0,1,2". This is required
                                          for automatic topic reassignment.
--execute [execute]                     This option does the actual
                                          reassignment. By default, the tool
                                          does a dry run
--manual-assignment-json-file <manual   The JSON file with the list of manual
  assignment json file path>              reassignments.This option or topics-
                                          to-move-json-file needs to be
                                          specified. The format to use is -
                                        {"partitions":
                                            [{"topic": "foo",
                                              "partition": 1,
                                              "replicas": [1,2,3] }],
                                        "version":1
                                        }
--topics-to-move-json-file <topics to   The JSON file with the list of topics
  reassign json file path>                to reassign.This option or manual-
                                          assignment-json-file needs to be
                                          specified. The format to use is -
                                        {"topics":
                                            [{"topic": "foo"},{"topic": "foo1"}],
                                        "version":1
                                        }
--zookeeper <urls>                      REQUIRED: The connection string for
                                          the zookeeper connection in the form
                                          host:port. Multiple URLS can be
                                          given to allow fail-over.

注意此工具默认运行在dry-run(预演)模式下,并不会初始化partiton movement。只有打开--execute选项,此工具才会开始执行。

 

集群扩展

在0.8版本中,此工具可以用来扩展(expand)一个已存在的集群。集群扩展涉及到引入了新的broker id。通常当为一个集群中新增一个broker时,它们不会从现存的topic接收到任何数据,直到使用这个工具把现存的topics/partitions assign到新的broker上。此工具使用2个选项来让批量转移topic到新的broker变得更简单,这2个选项分别为:a)要转移的topics;b)新增的broker的列表。使用这2个选项,此工具能自动的确定这些topic的partitions的位置。下面的例子把2个topic(foo1,foo2)转移到新增的broker(id为5,6,7)。

 

nnarkhed$ ./bin/kafka-reassign-partitions.sh --topics-to-move-json-file topics-to-move.json --broker-list "5,6,7" --execute
 
nnarkhed$ cat topics-to-move.json
{"topics":
     [{"topic": "foo1"},{"topic": "foo2"}],
     "version":1
}

 

选择一些partition进行转移

此工具也可以有选择的把一些特定的partition的一些replica转移到一个特定的broker。如果你有一个不负载不均衡的集群,你可以使用这个工具来有选择的转移一些partition。在这种模式下,此工具使用一个文件,文件包含了要转移的partition的列表,还有转移后replica分布的broker id列表。

下面的例子把一个partition的replica从broker 1,2,3转移到了broker 1,2,4上。

 

nnarkhed$ ./bin/kafka-reassign-partitions.sh --manual-assignment-json-file partitions-to-move.json --execute
 
nnarkhed$ cat partitions-to-move.json
{"partitions":
             [{"topic": "foo",
               "partition": 1,
               "replicas": [1,2,4] }],     
分享到:
评论

相关推荐

    Kafka Tool 2.0.7(windows 32\64).7z

    kafkatool 国内可能下载不了,搞32 64位的都压缩在一起了Kafka Tool 2.0.7( 32\64) To download the Kafka UI Tool for your operating system, use the links below. All versions of Kafka Tool come with a ...

    kafkatool (2.0版本).dmg

    kafka的开源客户端连接工具,简单易用,业内公认好用。使用教程网上众多,方便快速入门,使用门槛低,kafka的开源客户端连接工,kafka的开源客户端连接工,kafka的开源客户端连接工,kafka的开源客户端连接工

    kafkatool客户端工具

    kafkatool客户端工具,查询kafka中的信息。

    kafkatool 连接kafka工具

    kafka连接工具

    Kafka 可视化工具(Kafka Tool_windows_64bit).rar

    1、图形化界面可以直观地查看 Kafka 的 Topic 里的内容 2、自由设置 Kafka 数据展示格式 3、使用 Kafka Tool 创建/删除 Topic 4、使用 Kafka Tool 模拟发送 Messages

    kafkatool 2.0.9 Windows & maxOS & Linux

    kafkatool 2.0.9 Windows & maxOS & Linux

    kafkatool_64bit_v1.0.3.exe.zip

    To download the Kafka UI Tool for your operating system, use the links below. All versions of Kafka Tool come with a bundled JRE with the exception of the Linux version. For Linux, you must have Java ...

    kafkatool_64bit.exe.zip

    Kafka Tool is a GUI application for managing and using Apache Kafka ® clusters. It provides an intuitive UI that allows one to quickly view objects within a Kafka cluster as well as the messages ...

    kafkatool_64.zip

    Kafka Tool 2.0.7 kafka可视化管理工 使用Kafka的小伙伴,有没有为无法直观地查看 Kafka 的 Topic 里的内容而发过愁呢? 下面推荐给大家一款带有可视化页面的Kafka工具:Kafka Tool (目前最新版本是 2.0.4)

    Kafka Tool linux版本,适用于kafka0.11及以上

    Kafka Tool是一个用于管理和使用Apache Kafka集群的GUI应用程序。它提供了一个直观的UI,允许用户快速查看Kafka群集中的对象以及存储在群集主题中的消息

    kafkatool_64bit

    Kafka是一种高吞吐量的分布式发布订阅消息系统,它可以处理消费者规模的网站中的所有动作流数据。 这种动作(网页浏览,搜索和其他用户的行动)是在现代网络上的许多社会功能的一个关键因素。 这些数据通常是由于...

    KafkaTool_2.0.7.zip

    KafkaTool_2.0.7 dmg + 64bit-exe [For Kafka version 0.11 and later]

    Python库 | kafka-dev-tools-0.0.1.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:kafka-dev-tools-0.0.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    kafkatool.exe

    Kafka Tool是一个用于管理和使用Apache Kafka集群的GUI应用程序。它提供了一个直观的UI,允许用户快速查看Kafka群集中的对象以及存储在群集主题中的消息。它包含面向开发人员和管理员的功能。一些主要功能包括 快速...

    Kafka Tool 2.0.7(linux系统)

    下载文件解压后,直接运行bash kafkatool.sh后并选择yes即可完成安装

    kafka tool

    kafka tool kafka 可视化工具 mac,亲测可用,mac 10.14版本

    kafka学习之路

    kafka原理和架构及使用

    kafkatool-1.0.exe(kafka可视化工具)

    查看kafka上面数据的可视化工具, kafkatool-1.0.exe, 可以查看kafka 0.11以下版本:0.8, 0.9, 0.10

    kafka-connect-tools

    kafka-connect-tools

Global site tag (gtag.js) - Google Analytics