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

MongoDB 到 ClickHouse

选择对端数据库:

数据链路

基本功能

功能说明
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.

高级功能

功能说明
追加模式写入

INSERT 和 UPDATE 以追加模式批量写入, DELETE 单独通过 ALTER 方式执行

定时优化表

通过设置 autoOptimizeThresholdSec 参数,定时优化表

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

特殊操作

DELETE 操作过多(>50 条/秒)将大幅影响数据同步性能

目标端表引擎

仅支持以下表引擎以及对应的源端表类型:

  • MergeTree(无主键表)
  • ReplacingMergeTree(有主键表)
  • ReplicatedMergeTree(无主键表)
  • ReplicatedReplacingMergeTree(有主键表)

源端数据源

前置条件

条件说明
账号权限

文档:MongoDB 需要的权限

任务参数

参数名称说明
captureMode

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

changeStreamBatchSize

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

oplogCollection

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

timezone

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

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


目标端数据源

前置条件

条件说明
账号权限

具备 SELECT, INSERT, 常见 DDL 权限

网络准备

迁移同步节点(sidecar)可连接 ClickHouse 标准交互接口(如 8123)

任务参数

参数名称说明
multiReplica

是否为多副本集群

clusterName

集群名称,当 multiReplica 为 true, 则自动在 DDL/DML 中加入 ON CLUSTER clusterName 子句

ckTableEngine

当前支持以下表引擎:

  • MergeTree
  • ReplacingMergeTree
  • ReplicatedMergeTree
  • ReplicatedReplacingMergeTree
autoOptimizeThresholdSec

定时优化表(optimize table final)间隔,<=0 则关闭此功能

enableTimeRangeClamping

是否启用时间范围裁剪,强制将时间和日期值收束到 ClickHouse JDBC 的合法区间内,超出的数值将被截断至最小值或最大值。默认关闭(false)。

收束后范围(UTC):

  • Date:[1970-01-01, 2149-06-06]
  • Date32:[1925-01-01, 2283-11-11]
  • Timestamp:[1970-01-01 00:00:00, 2106-02-07 14:28:15]
  • Timestamp64:[1925-01-01 08:00:00.000, 2283-11-12 07:59:59.000]

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