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

PostgreSQL 到 ClickHouse

选择对端数据库:

数据链路

基本功能

功能说明
Schema Migration

If the target does not have the selected table, it will automatically generate and execute the creation statement on the target based on the source metadata and mapping.

Full Data Migration

Logical migration that sequentially scans the table data and writes it in batches to the target database.

Incremental Real-time Sync

Supports common DML sync for INSERT, UPDATE, and DELETE.

Data Verification

Performs full data verification and supports scheduling.

Modify Subscription

Add, delete, or modify subscription tables, with support for historical data migration. Documentation: Modify Subscription.

Reset Position

Supports rewinding the position based on file position or timestamp, allowing re-consumption of incremental logs from a specified Binlog file and position or a past period.

Table Name Mapping

Supports keep consistent with the source, convert to lowercase, convert to uppercase, and truncate with '_number' suffix.

DDL Sync

PostgreSQL DDL sync is realized by triggers. The user should have the permissions on triggers and tables. For more information, see Permissions Required for PostgreSQL

  • ALTER TABLE ADD COLUMN, DROP COLUMN, MODIFY COLUMN, CHANGE COLUMN
  • CREATE TABLE (full database sync)
Metadata Retrieval

Queries the target from the source table, with support for filter conditions and primary key settings.

高级功能

功能说明
追加模式写入

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

定时优化表

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

Scheduled Full Migration

Documentation 1: Create Scheduled Full Task
Documentation 2: Use Scheduled Full Migration for Incremental Data.

Custom Code

Documentation 1: Create a Custom Code Task
Documentation 2: Debug Custom Code Task
Documentation 3: Log in Custom Code.

Data Filtering Conditions

Supports WHERE conditions for data filtering, using SQL 92 subset. Documentation: Create Data Filter Task.

Set Target Primary Key

Change the primary key to another field for easier data aggregation and operations.

Add Virtual Columns

Supports adding custom virtual columns with fixed values, such as region or ID.

限制和注意点

限制项说明
特殊操作

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

目标端表引擎

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

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

源端数据源

前置条件

条件说明
账号权限

需要权限如下(以自建数据库为例):

  • GRANT ALL PRIVILEGES ON DATABASE 同步库 TO 同步账号(或同步库 information_schema 中所有视图的 SELECT 权限和需要同步表、索引、约束的 SELECT 权限)
  • ALTER USER 同步账号 REPLICATION
增量同步准备

准备动作按如下步骤进行:

  • 修改 postgresql.conf, 设置 wal_level=logical 和 wal_log_hints = on
  • 修改 pg_hba.conf, 设置 host replication 同步账号 CIDR网段 md5 , host 同步库 同步账号 CIDR网段 md5, host postgres 同步账号 CIDR网段 md5
  • 重启 PostgreSQL
网络准备

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

任务参数

参数名称说明
fullFetchSize

全量扫描数据设置的 fetch size

eventStoreSize

缓存解析完毕的增量事件缓存大小

ignoreGisSRID

解析 GIS 数据类型时是否忽略 SRID

defaultGisSRID

设置 GIS 数据类型的 SRID

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: 通用参数配置请参考 通用参数及功能