kafka机器下线操作&上线操作

1.下线操作

1.步骤一

新建一个文件名为topics-to-move.json文件内容为需要转移的topic

{"topics": [
{"topic": "__consumer_offsets"},
{"topic": "click_stream_topic"},
{"topic": "directory_topic"},
{"topic": "DP_monitor_consumer_topic"},
{"topic": "DP_monitor_provider_topic"},
{"topic": "EC_user_event_rt_topic"},
{"topic": "kafka_topic"}
],
"version":1
}

2.步骤二

执行以下操作命令,比如下线0号机器,把0上的数据都移到1,2上,脚本内容

bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --topics-to-move-json-file topics-to-move.json --broker-list "1,2" --generate

image.png

将新生产的json串赋值到expand-cluster-reassignment.json文件中,

image.png

3.步骤三

开始执行转移数据操作

bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file expand-cluster-reassignment.json --execute
image.png

使用以下命令查看状态

  bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file expand-cluster-reassignment.json --verify

效果,如下图所示,数据转移完成


image.png

按照上述步骤将所有的0上的topic都转移到1,2服务器上,0号机器下线升级系统

2.上线操作

与下线操作原理一样

1.步骤一

执行以下操作命令,把数据都转移到0,1,2上,执行以下脚本

bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --topics-to-move-json-file topics-to-move.json --broker-list "0,1,2" --generate
image.png

2.将内容copy到expand-cluster-reassignment2.json文件中,执行以下命令

bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file expand-cluster-reassignment2.json --execute
image.png

使用以下命令查看状态

  bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file expand-cluster-reassignment2.json --verify
image.png

效果数据恢复

image.png

3.总结

测试环境数据量较少,转移非常快,线上环境,topic较多,partitions数量也多,转移数据较慢,一次不要操作太多topic,需要耐心等待观察。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,146评论 19 139
  • 8086汇编 本笔记是笔者观看小甲鱼老师(鱼C论坛)《零基础入门学习汇编语言》系列视频的笔记,在此感谢他和像他一样...
    Gibbs基阅读 37,798评论 8 114
  • 如果要写墓志铭的话,他希望将来的墓碑上刻上这一句话:这里躺着一个33岁才开始践行的人。 在这之前,他一直在浑浑噩噩...
    段春涛涛阅读 1,252评论 0 0
  • E64 The president said the United States would send up to...
    一日一译阅读 1,540评论 0 1
  • 欢迎加QQ群讨论:157672725 文章 1.如何在 iOS 上实现类似 Airbnb 中的可展开式菜单 : 如...
    CatchZeng阅读 3,823评论 0 2

友情链接更多精彩内容