BladePipe 1.9.0: New data pipelines, faster Oracle writes, and improved stability.
跳到主要内容

MongoDB 到 StarRocks

选择对端数据库:

数据链路

基本功能

功能说明
Full Data Migration

Migrate data by sequentially scanning data in tables and writing it in batches to the target database. Supported _id types: ObjectId, Long, Integer.

Incremental Data Sync

Sync of INSERT, UPDATE, DELETE is supported.

Data Verification and Correction

Verify all existing data. Optionally, you can correct the inconsistent data based on verification results. Scheduled DataTasks are supported.
For more information, see Create Verification and Correction DataJob.

Subscription Modification

Add, delete, or modify the subscribed tables with support for historical data migration. For more information, see Modify Subscription.

Position Resetting

Reset positions by timestamp to consume the oplog in a past period again.

Supported Deployment

Support master-slave, replica set, sharded cluster.

Table Name Mapping

Support the mapping rules, namely, keeping the name the same as that in Source, converting the text to lowercase, converting the text to uppercase, truncating the name by "_digit" suffix.

高级功能

功能说明
全量前清空目标数据

运行全量任务前清除老数据,包括重跑任务、定时全量迁移都会触发此能力

重建目标表

运行全量任务前重建目标表,包括重跑任务、定时全量迁移都会触发此能力

Stream Load 数据写入

采用 Stream Load 到 StarRocks Be 写入数据, 默认攒批写入,可动态调节刷出数据节奏和批次大小

0 值时间处理

支持将 0 值时间设置成不同类型的值,防止写入对端报错

Custom Code

For more information, see Custom Code Processing, Debug Custom Code and Logging in Custom Code.

Adding Virtual Columns

Support adding custom virtual columns with fixed values, such as region, ID, etc.

限制和注意点

限制项说明
oplog 大小和保留时间设置

MongoDB 默认配置 replication.oplogSizeMB 过小 或 storage.oplogMinRetentionHours 过小,如数据同步延迟过大,可能导致未消费的 oplog 被清除,需调大此参数

MongoDB 主备架构的任务设置

源端 MongoDB 主备架构模式,需要将源端任务参数 oplogCollection 设置为 oplog.$main

changeStream 模式

MongoDB 3.6 以上支持 changeStream 获取增量变更,同步任务可以设置源端参数 captureModeCHANGE_STREAM,MongoDB 分片集群可以填写 Mongos 连接串进行同步

oplog 模式

当使用 oplog 模式进行 MongoDB 源端同步时,需要确保该能够访问到 local

对端表类型

仅支持 主键模型(Primary Key)

源端表类型

不支持 无主键表 迁移同步

DDL 同步报错
  • 同一张表连续几个 DDL 将报错(因 StarRocks 对端是异步 DDL)
  • 修改字段约束或者部分类型的 DDL 报错
  • 如遇到 DDL 报错,可在对端变更好表结构,然后通过设置任务参数跳过,文档:跳过 DDL 异常
增量写入冲突策略

Stream Load 写入以主键进行整行替换


源端数据源

前置条件

条件说明
账号权限

文档:MongoDB 需要的权限

任务参数

参数名称说明
captureMode

配置 MongoDB 增量源端模式,支持 OP_LOG 和 CHANGE_STREAM 模式

changeStreamBatchSize

配置 MongoDB Change Stream 每一批拉取变更事件的最大条数

oplogCollection

配置 MongoDB oplog 的集合名,默认是 oplog.rs

timezone

需要转换的源端时区(默认 UTC)

Tips: 通用参数配置请参考 通用参数及功能


目标端数据源

前置条件

条件说明
账号权限

具备 SELECT, DDL 权限(可选)

网络准备

迁移同步节点(sidecar)可连接 StarRocks FE QueryPortFE/BE HttpPort

任务参数

参数名称说明
host

MySQL 协议交互链接,对应 StarRocks FE QueryPort

httpHost

StarRocks stream load 链接,对应 StarRocks FE/BE HttpPort

totalDataInMemMb

攒批写入,内存中最大数据容量,超过此容量或超过 asyncFlushIntervalSec 则刷出数据到写入队列

asyncFlushIntervalSec

攒批写入,等待刷出的间隔时间,超过此时间或超过 totalDataInMemMb 则刷出数据到写入队列

flushBatchMb

单表最大攒批容量,超过此容量则刷出数据到写入队列

realFlushPauseSec

使用 stream load 刷出数据到 StarRocks 的等待时间,0 则不等待

soTimeoutSec

在 QueryPort 执行操作时 tcp 超时链接 (so_timeout)

httpSoTimeoutSec

在 HttpPort 执行操作时 tcp 超时链接 (so_timeout)

enableTimeZoneProcess

是否对时间字段进行时区转换

timezone

目标端 StarRocks 时区,例如 +08:00 Asia/Shanghai America/New_York

maxInSizePerQuery

校验任务中,对端单次查询的最大 IN 条件值数量,大于该值会自动拆分多次查询

Tips: 通用参数配置请参考 通用参数及功能