博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
kafka 扩容之后迁移topic
阅读量:6157 次
发布时间:2019-06-21

本文共 2289 字,大约阅读时间需要 7 分钟。

hot3.png

1. 准备移动

  • 这里假设要移动的topic名称为:topicA、topicB
vim topics-to-move.json{"topics": [{"topic": "topicA"},            {"topic": "topicB"}],"version":1}
  • 将上述 topic 移动到 broker 3,4,5上,用 generate 命令生成 partition 分配 json 串,如下:
bin/kafka-reassign-partitions.sh --zookeeper zk1:2181 --topics-to-move-json-file topics-to-move.json --broker-list "3,4,5" --generate
  • 将看到如下:
Current partition replica assignment{"version":1,"partitions":[{"topic":"topicA","partition":2,"replicas":[0,2]},{"topic":"topicA","partition":1,"replicas":[1,0]},{"topic":"topicB","partition":1,"replicas":[0,1]},{"topic":"topicA","partition":0,"replicas":[2,1]},{"topic":"topicB","partition":0,"replicas":[2,0]},{"topic":"topicB","partition":2,"replicas":[1,2]}]}Proposed partition reassignment configuration{"version":1,"partitions":[{"topic":"topicA","partition":2,"replicas":[3,4]},{"topic":"topicA","partition":1,"replicas":[5,3]},{"topic":"topicB","partition":1,"replicas":[3,4]},{"topic":"topicA","partition":0,"replicas":[4,5]},{"topic":"topicB","partition":0,"replicas":[5,3]},{"topic":"topicB","partition":2,"replicas":[4,5]}]}

2. 执行移动

  • 将 Proposed partition reassignment configuration 下方的数据写入 expand-cluster-reassignment.json
vim expand-cluster-reassignment.json{"version":1,"partitions":[{"topic":"topicA","partition":2,"replicas":[3,4]},{"topic":"topicA","partition":1,"replicas":[5,3]},{"topic":"topicB","partition":1,"replicas":[3,4]},{"topic":"topicA","partition":0,"replicas":[4,5]},{"topic":"topicB","partition":0,"replicas":[5,3]},{"topic":"topicB","partition":2,"replicas":[4,5]}]}
  • 用 execute 命令开始正式执行,将会把上述2个topic按 expand-cluster-reassignment 中的设置进行分配,该过程可能会影响其它topic的读取(延时)
bin/kafka-reassign-partitions.sh --zookeeper zk1:2181 --reassignment-json-file expand-cluster-reassignment.json --execute

3. 查看状态

  • 查询执行状态
bin/kafka-reassign-partitions.sh --zookeeper zk1:2181 --reassignment-json-file expand-cluster-reassignment.json --verify
  • 主要有几种状态
Reassignment of partition [topicA,4] is still in progress # 转移中Reassignment of partition [topicB,2] completed successfully # 转移结束
  • 如果你看到如下方的ERROR信息,没关系,不要关闭节点,过会再看看就正常了
ERROR: Assigned replicas (0,5,1,2,3,4) don't match the list of replicas for reassignment (5,3,4) for partition [topicA,3]Reassignment of partition [topicA,3] failed

转载于:https://my.oschina.net/remainsu/blog/1816010

你可能感兴趣的文章
将标题空格替换为 '_' , 并自动复制到剪切板上
查看>>
List Collections sort
查看>>
Mysql -- You can't specify target table 'address' for update in FROM clause
查看>>
使用局部标准差实现图像的局部对比度增强算法。
查看>>
2017-2018-1 20165313 《信息安全系统设计基础》第八周学习总结
查看>>
《代码敲不队》第四次作业:项目需求调研与分析
查看>>
菜鸡互啄队—— 团队合作
查看>>
HttpWebRequest的GetResponse或GetRequestStream偶尔超时 + 总结各种超时死掉的可能和相应的解决办法...
查看>>
SparseArray
查看>>
第二章
查看>>
android背景选择器selector用法汇总
查看>>
[转]Paul Adams:为社交设计
查看>>
showdialog弹出窗口刷新问题
查看>>
java
查看>>
Vue.js连接后台数据jsp页面  ̄▽ ̄
查看>>
关于程序的单元测试
查看>>
mysql内存优化
查看>>
都市求生日记第一篇
查看>>
Java集合---HashMap源码剖析
查看>>
SQL优化技巧
查看>>