kafka数据迁移

kafka默认只保存7天的数据

1.在新节点上搭建kafka服务

机器一原本有节点broker.id分别为1,2
在机器而上新增节点broker.id为3,4

2.启动kafka服务

3.查看需要移动的topics

查看所有主题

kafka-topics.sh --list --zookeeper 59.110.153.152:2181

将topic写入新文件topics-to-move.json中,格式如下
{“topics”: [

{“topic”: “fortest1”},

{“topic”: “fortest2”},

{“topic”: “fortest3”}

],

“version”:1

}

4生成移动脚本

3,4是新节点的broker.id
运行bin/kafka-reassign-partitions.sh --zookeeper 59.110.153.152:2181 --topics-to-move-json-file topics-to-move.json --broker-list “3,4” --generate

生成新的json数据
{“version”:1,“partitions”:[{“topic”:“fortest1”,“partition”:0,“replicas”:[3,4]},其他部分省略}

将这一串json写入新文件reassignment-node.json中

5.开始迁移

bin/kafka-reassign-partitions.sh --zookeeper 59.110.153.152:2181 --reassignment-json-file reassignment-node.json --execute

6.数据完成迁移后, 老的服务先别停.

7.修改所有客户端producer或者consumer连接指向新节点.

8.查看是否成功

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值