一、前提条件
·已 购买云上 CKafka 实例。
·已 迁移 Topic 上云。
二、操作步骤
1. 下载 MirrorMaker 工具 并解压到本地。
注意:说明:
注意:这篇以 kafka_2.11-1.1.1.tgz 为例。
2. 配置 consumer.properties 文件。
# list of brokers used for bootstrapping knowledge about the rest of the cluster# format: host1:port1,host2:port2 …bootstrap.servers=localhost:9092# consumer group idgroup.id=test-consumer-grouppartition.assignment.strategy=org.apache.kafka.clients.consumer.RoundRobinAssignor# What to do when there is no initial offset in Kafka or if the current# offset does not exist any more on the server: latest, earliest, none#auto.offset.reset=
| 参数 | 说明 |
| bootstrap.servers | 自建实例的 broker 接入点列表。 |
| group.id | 迁移数据时用到的消费者组 ID,请勿与自建实例已存在的消费者命名重复冲突。 |
| partition.assignment.strategy | 分区分配的策略,以partition.assignment.strategy=org.apache.kafka.clients.consumer.RoundRobinAssignor 为例。 |
3. 配置 producer.properties 文件。
# list of brokers used for bootstrapping knowledge about the rest of the cluster# format: host1:port1,host2:port2 …bootstrap.servers=localhost:9092# specify the compression codec for all data generated: none, gzip, snappy, lz4compression.type=none
| 参数 | 说明 |
| bootstrap.servers | 云上实例的接入网络,在控制台的实例详情页面接入方式模块的网络列复制。 |
| compression.type | 数据压缩类型,CKafka 不支持 GZip 压缩格式。 |
4. 在 .bin 目录下启动 mirrormaker 迁移工具开始迁移。
sh bin/kafka-mirror-maker.sh –consumer.config config/consumer.properties –producer.config config/producer.properties –whitelist topicName
注意:说明:
注意:whitelist 为正则表达式,迁移匹配正则名称的 Topic。
5. 在 .bin 目录下运行kafka-consumer-groups.sh查看自建集群消费进度。
bin/kafka-consumer-groups.sh –new-consumer –describe –bootstrap-server自建集群接入点 –group test-consumer-group
注意:说明:
注意:group 指迁移数据时用到的消费者组 ID。
三、后续处理
数据迁移完成后,将客户端的生产消费配置转到云上实例的接入点。