Automatically migrating data to new machines kafka集群扩充迁移topic
The partition reassignment tool can be used to move some topics off of the current set of brokers to the newly added brokers. This is typically useful while expanding an existing cluster since it is easier to move entire topics to the new set of brokers, than moving one partition at a time. When used to do this, the user should provide a list of topics that should be moved to the new set of brokers and a target list of new brokers. The tool then evenly distributes all partitions for the given list of topics across the new set of brokers. During this move, the replication factor of the topic is kept constant. Effectively the replicas for all partitions for the input list of topics are moved from the old set of brokers to the newly added brokers.
For instance, the following example will move all partitions for topics foo1,foo2 to the new set of brokers 5,6. At the end of this move, all partitions for topics foo1 and foo2 will only exist on brokers 5,6.
Since the tool accepts the input list of topics as a json file, you first need to identify the topics you want to move and create the json file as follows:
1
2
3
4
5
|
> cat topics-to-move.json { "topics" : [{ "topic" : "foo1" }, { "topic" : "foo2" }], "version" :1 } |
Once the json file is ready, use the partition reassignment tool to generate a candidate assignment:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
> bin /kafka-reassign-partitions .sh --zookeeper localhost:2181 --topics-to-move-json- file topics-to-move.json --broker-list "5,6" --generate Current partition replica assignment { "version" :1, "partitions" :[{ "topic" : "foo1" , "partition" :2, "replicas" :[1,2]}, { "topic" : "foo1" , "partition" :0, "replicas" :[3,4]}, { "topic" : "foo2" , "partition" :2, "replicas" :[1,2]}, { "topic" : "foo2" , "partition" :0, "replicas" :[3,4]}, { "topic" : "foo1" , "partition" :1, "replicas" :[2,3]}, { "topic" : "foo2" , "partition" :1, "replicas" :[2,3]}] } Proposed partition reassignment configuration { "version" :1, "partitions" :[{ "topic" : "foo1" , "partition" :2, "replicas" :[5,6]}, { "topic" : "foo1" , "partition" :0, "replicas" :[5,6]}, { "topic" : "foo2" , "partition" :2, "replicas" :[5,6]}, { "topic" : "foo2" , "partition" :0, "replicas" :[5,6]}, { "topic" : "foo1" , "partition" :1, "replicas" :[5,6]}, { "topic" : "foo2" , "partition" :1, "replicas" :[5,6]}] } |
The tool generates a candidate assignment that will move all partitions from topics foo1,foo2 to brokers 5,6. Note, however, that at this point, the partition movement has not started, it merely tells you the current assignment and the proposed new assignment. The current assignment should be saved in case you want to rollback to it. The new assignment should be saved in a json file (e.g. expand-cluster-reassignment.json) to be input to the tool with the --execute option as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
> bin /kafka-reassign-partitions .sh --zookeeper localhost:2181 --reassignment-json- file expand -cluster-reassignment.json --execute Current partition replica assignment { "version" :1, "partitions" :[{ "topic" : "foo1" , "partition" :2, "replicas" :[1,2]}, { "topic" : "foo1" , "partition" :0, "replicas" :[3,4]}, { "topic" : "foo2" , "partition" :2, "replicas" :[1,2]}, { "topic" : "foo2" , "partition" :0, "replicas" :[3,4]}, { "topic" : "foo1" , "partition" :1, "replicas" :[2,3]}, { "topic" : "foo2" , "partition" :1, "replicas" :[2,3]}] } Save this to use as the --reassignment-json- file option during rollback Successfully started reassignment of partitions { "version" :1, "partitions" :[{ "topic" : "foo1" , "partition" :2, "replicas" :[5,6]}, { "topic" : "foo1" , "partition" :0, "replicas" :[5,6]}, { "topic" : "foo2" , "partition" :2, "replicas" :[5,6]}, { "topic" : "foo2" , "partition" :0, "replicas" :[5,6]}, { "topic" : "foo1" , "partition" :1, "replicas" :[5,6]}, { "topic" : "foo2" , "partition" :1, "replicas" :[5,6]}] } |
Finally, the --verify option can be used with the tool to check the status of the partition reassignment. Note that the same expand-cluster-reassignment.json (used with the --execute option) should be used with the --verify option:
1
2
3
4
5
6
7
8
|
> bin /kafka-reassign-partitions .sh --zookeeper localhost:2181 --reassignment-json- file expand -cluster-reassignment.json --verify Status of partition reassignment: Reassignment of partition [foo1,0] completed successfully Reassignment of partition [foo1,1] is in progress Reassignment of partition [foo1,2] is in progress Reassignment of partition [foo2,0] completed successfully Reassignment of partition [foo2,1] completed successfully Reassignment of partition [foo2,2] completed successfully |
注意:
The partition reassignment tool does not have the ability to automatically generate a reassignment plan for decommissioning brokers yet. As such, the admin has to come up with a reassignment plan to move the replica for all partitions hosted on the broker to be decommissioned, to the rest of the brokers. This can be relatively tedious as the reassignment needs to ensure that all the replicas are not moved from the decommissioned broker to only one other broker. To make this process effortless, we plan to add tooling support for decommissioning brokers in the future.
Automatically migrating data to new machines kafka集群扩充迁移topic的更多相关文章
- Custom partition assignment and migration kafka集群扩充迁移指定partition
The partition reassignment tool can also be used to selectively move replicas of a partition to a sp ...
- Zookeeper+Kafka集群部署(转)
Zookeeper+Kafka集群部署 主机规划: 10.200.3.85 Kafka+ZooKeeper 10.200.3.86 Kafka+ZooKeeper 10.200.3.87 Kaf ...
- 《Apache kafka实战》读书笔记-管理Kafka集群安全之ACL篇
<Apache kafka实战>读书笔记-管理Kafka集群安全之ACL篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 想必大家能看到这篇博客的小伙伴,估计你对kaf ...
- kafka集群环境搭建(Linux)
一.准备工作 centos6.8和jvm需要准备64位的,如果为32位,服务启动的时候报java.lang.OutOfMemoryError: Map failed 的错误. 链接:http://pa ...
- Zookeeper+Kafka集群部署
Zookeeper+Kafka集群部署 主机规划: 10.200.3.85 Kafka+ZooKeeper 10.200.3.86 Kafka+ZooKeeper 10.200.3.87 Kaf ...
- CentOS6安装各种大数据软件 第五章:Kafka集群的配置
相关文章链接 CentOS6安装各种大数据软件 第一章:各个软件版本介绍 CentOS6安装各种大数据软件 第二章:Linux各个软件启动命令 CentOS6安装各种大数据软件 第三章:Linux基础 ...
- kafka集群部署以及单机部署
kafka单机部署 一.环境准备 当前环境:centos7.3一台软件版本:kafka_2.12部署目录:/usr/local/kafka启动端口:9092配置文件:/usr/local/kafk ...
- 六十一.常用组件 、 Kafka集群 、 Hadoop高可用
1.Zookeeper安装搭建Zookeeper集群并查看各服务器的角色停止Leader并查看各服务器的角色 1.1 安装Zookeeper1)编辑/etc/hosts ,所有集群主机可以相互 pin ...
- ELK+Kafka集群日志分析系统
ELK+Kafka集群分析系统部署 因为是自己本地写好的word文档复制进来的.格式有些出入还望体谅.如有错误请回复.谢谢! 一. 系统介绍 2 二. 版本说明 3 三. 服务部署 3 1) JDK部 ...
随机推荐
- 第一册:lesson twentynine..
原文:Come in ,Amy. A:Come in B. Shut the door,please. This bedroom's very untidy. B:What must I do Mrs ...
- JQuery官方学习资料(译):避免与其他库的冲突
避免与其他库的冲突 JQuery库和它所有的插件都是包含在jQuery命名空间下的,作为一般规则,全局对象被存储在jQuery的命名空间内,所以你不会得到jQuery和任何其他库之间的冲突(例 ...
- python之strip()小记
描述 Python strip() 方法用于移除字符串头尾指定的字符(默认为空格或换行符)或字符序列. 注意:该方法只能删除开头或是结尾的字符,不能删除中间部分的字符. 语法 strip()方法语法: ...
- 【Spring】31、Spring的EL表达式
一.简介 Spring3中引入了Spring表达式语言—SpringEL,SpEL是一种强大,简洁的装配Bean的方式,他可以通过运行期间执行的表达式将值装配到我们的属性或构造函数当中,更可以调用JD ...
- Java8 方法引用
概述 方法引用是用来直接访问类或实例阴茎存在的方法或者构造方法.它需要由兼容的函数式接口(lambda表达式中用到的接口)构成的目标类型上下文. 有时候, 当我们想要实现一个函数式接口的方法, 但是已 ...
- Spring之AOP在XML中的配置方法
AOP 即 Aspect Oriental Program 面向切面编程 先来一个栗子: <aop:config> <aop:pointcut id="loggerCutp ...
- Spring 切入点配置
有关各种拦截的切入点配置举例 (1)只对返回值为String的方法进行拦截 @Pointcut("execution (java.lang.String com.zzdr.spring.se ...
- clipboard.js -- js实现将文本复制到剪贴板的方法
资源 推荐使用:clipboard.js 官方教程地址:https://clipboardjs.com/#example-text 官方github地址:https://github.com/zeno ...
- uni-app 如何在当前页调上个页面的方法
1.获取上个页面 var pages = getCurrentPages();//当前页 var beforePage = pages[pages.length - 2];//上个页面 2.在当前页调 ...
- eclipse安装中java环境的搭建
转自博客园:amandaj 做了小小改动. 一.java 开发环境的搭建 这里主要说的是在windows 环境下怎么配置环境. 1.首先安装JDK java的sdk简称JDK ,去其官方网站下载最近 ...