跳到主要内容

PostgreSQL

选择对端数据库:

数据链路

基本功能

功能说明
结构迁移

如目标不存在所选表,则自动根据源端元数据,结合映射生成对端创建语句并执行创建

全量数据迁移

逻辑迁移,通过顺序扫描表数据,将数据分批写入到对端数据库

增量实时同步

支持 INSERT, UPDATE, DELETE 常见 DML 同步

数据校验和订正

全量数据校验,并可选根据校验结果订正差异数据,支持定时,文档:创建定时校验订正任务

修改订阅

新增、删除、修改订阅表,支持历史数据迁移,文档:修改订阅

表名映射

支持 和源端保持一致, 转小写, 转大写, 以'_数字'后缀截取

DDL 同步

PostgreSQL DDL 同步基于 触发器 实现,需具备相应的 触发器 权限。文档:PostgreSQL 需要的权限

元数据检索

从源端表查对端,查询设置过过滤条件的

高级功能

功能说明
Handling of Zero Value for Time

Allow setting zero value for time to different data types to prevent errors when writing to the Target.

自定义代码

文档1:创建自定义代码任务
文档2:自定义代码任务 debug
文档3:在自定义代码中打日志

数据过滤条件

支持 WHERE 条件进行数据过滤,内容为 SQL 92 子集,文档:创建数据过滤任务

设置目标主键

变更主键为其他字段,方便数据聚合等操作

限制和注意点

限制项说明
Primary Key Conflict Handling

PostgreSQL <= 9.4 or Greenplum <= 6 does not support conflict skipping or replacement. Performance may be affected when there are a large number of primary key conflicts.


源端数据源

前置条件

条件说明
Permissions for Account

Required permissions (taking a self-managed database as an example):

  • GRANT ALL PRIVILEGES ON DATABASE sync_db TO sync_user (or SELECT permission on all views in the sync_db information_schema, and SELECT permission on tables, indexes, constraints to be synchronized)
  • ALTER USER sync_user REPLICATION
Incremental Data Sync Preparation

Prepare as follows:

  • Modify postgresql.conf, set wal_level=logical and wal_log_hints=on
  • Modify pg_hba.conf, set host replication sync_user CIDR netmask md5, host sync_db sync_user CIDR netmask md5, host postgres sync_user CIDR netmask md5
  • Restart PostgreSQL
Port Preparation

Allow the migration and sync node (Worker) to connect to the PostgreSQL port (e.g., port 5432).

任务参数

参数名称说明
fullFetchSize

Fetch size for scaning full data.

eventStoreSize

Cache size for parsed incremental events.

ignoreGisSRID

Whether to ignore SRID when parsing GIS data types.

defaultGisSRID

Set the SRID for GIS data types.

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


目标端数据源

前置条件

条件说明
Permissions for Account

Required permissions include SELECT, INSERT, DELETE, UPDATE, and common DDL permissions.
For Aliyun AnalyticDB for PostgreSQL, initial accounts or those with SELECT, INSERT, DELETE, UPDATE, and common DDL permissions are needed.

Port Preparation

Allow the migration and sync node (Worker) to connect to the PostgreSQL / Greenplum / Aliyun AnalyticDB for PostgreSQL port (e.g., port 5432).

任务参数

参数名称说明
keyConflictStrategy

Strategy for handling primary key conflicts during write in Incremental DataTask:

  • IGNORE: Ignore conflicts (default)
  • REPLACE: Replace conflicts (optional)

dstWholeReplace

Convert INSERT and UPDATE operations into full row replacement in the Target.

enableTimeZoneProcess

Enable time zone conversion to datetime fields.

timezone

Target time zone, e.g., +08:00, Asia/Shanghai, America/New_York.

defaultZeroDate

Default value for replacing '0000-00-00 00:00:00' / '0000-00-00' values. Optional values include:

  • null (empty)
  • Time (14:23:33)
  • Date (1970-01-01)
  • DateTime (1970-01-01 00:00:00),
  • TimeZone Time (14:23:33+08:00 or 1970-01-01 00:00:00+08:00)
caseSensitive

Case sensitivity strategy for SQL statements, including:

  • UpperCase: Convert to uppercase
  • LowerCase: Convert to lowercase
  • Sensitive: Add qualifiers
  • NoSpecified: No conversion/No qualifiers

writeStrategy

Strategy of writing data to the Target, including:

  • ROW (single row)
  • MULTI_SQL (multiple statements)
  • BATCH (write data in batches, default option)
  • COPY (PostgreSQL COPY command)
defaultGisSRID

Set the SRID for GIS data types.

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

数据链路

基本功能

高级功能

限制和注意点

使用示例

链路FAQ

源端数据源

前置条件

任务参数

目标端数据源

前置条件

任务参数