简介 #
FlinkCDC(Change Data Capture)是 SmartPip 提供的实时数据同步方案,支持数据库变更捕获、自动建表、结构变更感知等功能。通过配置 flinkcdc 驱动即可实现源库到目标库的实时同步。
FlinkCDC 特性速查 #
| 特性 | 说明 |
|---|---|
| 自动建表 | 自动在目标库创建与源库相同的表 |
| 结构变更感知 | 自动感知源表结构变化并同步 |
| 整库同步 | 支持一个任务同步整个数据库 |
| 批量路由 | 支持自定义表名映射和转换规则 |
同步任务说明 #
同步任务说明 #
- 全自动建表并能自动感知源表结构变化,自动变化
- 支持整库同步, 因此建议针对一个数据源只需启动一个任务即可
- 实时同步任务启动后, 定时任务为自动监控任务
- 如果修改任务后需在flink web中先取消任务后再可提交生效
简单的全库同步设定 #
比如源库为training, 则会自动在目标源建相同名称的库和表
##template = test_starrocks_flink
##name = test_starrocks2
##tables = training.\.*
##config =
批量路由 #
##template = test_starrocks_flink
##name = test_starrocks2
##tables = source_db.\.*
##config=
route:
- source-table: source_db.\.*
sink-table: sink_db.<>
replace-symbol: <>
description: route all tables in source_db to sink_db
自定义路由或转化 #
##template = test_starrocks_flink
##name = test_starrocks2
##tables = adb.\.*, bdb.user_table_[0-9]+, [app|web]_order_\.*
##config=
transform:
- source-table: mydb.web_order
projection: \*, UPPER(product_name) as product_name
description: project fields with wildcard character from source table
- source-table: mydb.app_order
projection: UPPER(product_name) as product_name, *
description: project fields with wildcard character from source table
- source-table: mydb.web_order
projection: id, order_id, UPPER(province) as new_province
filter: new_province = 'SHANGHAI'
description: filtering rows based on computed columns
route:
- source-table: app_db.orders
sink-table: ods_db.ods_orders
- source-table: app_db.shipments
sink-table: ods_db.ods_shipments