flinkCDC mysql

1.首先必须在要同步到源端和目标端创建好表

2.源端flinksql语句如下:

sql 复制代码
DROP TABLE IF EXISTS FLINK_SOURCE_hrpt_dtl;
create table FLINK_SOURCE_hrpt_dtl(
`template_dtl_id`bigint NOT NULL ,
  `template_id`bigint NOT NULL COMMENT '报表模板ID,hrpt_template.template_id',
  `template_url` varchar(480)   COMMENT '模板路径',
  `template_content` string  COMMENT '模板内容',
  `lang` varchar(30)  NOT NULL COMMENT '模板语言',
  `enabled_flag` tinyint NOT NULL  COMMENT '启用标识',
  `tenant_id`bigint NOT NULL  COMMENT '租户ID,hpfm_tenant.tenant_id',
  `object_version_number`bigint NOT NULL  COMMENT '行版本号,用来处理锁',
  `creation_date` timestamp NOT NULL,
  `created_by`bigint NOT NULL ,
  `last_updated_by`bigint NOT NULL ,
  `last_update_date` timestamp NOT NULL,
	PRIMARY KEY (`template_dtl_id`) NOT ENFORCED
)with (
'connector' = 'mysql-cdc',
'hostname' = '1.6.2.13',
'port' = '3306',
'username' = 'test',
'password' = 'test@123',
'database-name' = 'report',
'table-name' = 'hrpt_dtl',
'scan.incremental.snapshot.enabled' = 'false',
'debezium.database.tablename.case.insensitive' = 'false',
'debezium.log.mining.strategy' = 'online_catalog',
'server-time-zone' = 'Asia/Shanghai',
'debezium.log.mining.continuous.mine' = 'true'
);

3.目标端flinksql模板

sql 复制代码
DROP TABLE IF EXISTS FLINK_TARGET_hrpt_dtl;
create table FLINK_TARGET_hrpt_dtl(
`template_dtl_id`bigint NOT NULL ,
  `template_id`bigint NOT NULL COMMENT '报表模板ID,hrpt_template.template_id',
  `template_url` varchar(480)   COMMENT '模板路径',
  `template_content` string  COMMENT '模板内容',
  `lang` varchar(30)  NOT NULL COMMENT '模板语言',
  `enabled_flag` tinyint NOT NULL  COMMENT '启用标识',
  `tenant_id`bigint NOT NULL  COMMENT '租户ID,hpfm_tenant.tenant_id',
  `object_version_number`bigint NOT NULL  COMMENT '行版本号,用来处理锁',
  `creation_date` timestamp NOT NULL,
  `created_by`bigint NOT NULL ,
  `last_updated_by`bigint NOT NULL ,
  `last_update_date` timestamp NOT NULL,
	PRIMARY KEY (`template_dtl_id`) NOT ENFORCED
)with (
'connector' = 'jdbc',
'url' = 'jdbc:mysql://10.6.28.10:3306/cdc?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&serverTimezone=Asia/Shanghai',
'username' = 'test',
'password' = 'test@123',
'table-name' = 'hrpt_dtl',
'driver' = 'com.mysql.jdbc.Driver',
'scan.fetch-size' = '200'
);

4.把源端数据插入到目标端

sql 复制代码
insert into FLINK_TARGET_hrpt_dtl select * from FLINK_TARGET_hrpt_dtl ;

以上就是flink_CDC的全部过程。

相关推荐
风景_fengjing37 分钟前
ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
服务器·数据库·oracle
HGW6891 小时前
基于MyBatis插件实现动态表名解决多环境单一数据库问题
数据库·mybatis
SEO-狼术1 小时前
ComponentOne Studio Enterprise 2025
数据库
睡觉待开机1 小时前
2. 库的操作
数据库·oracle·dba
才华是浅浅的耐心1 小时前
Facebook用户信息爬虫技术分析与实现详解
数据库·爬虫·python·facebook
Python之栈2 小时前
Python 隐藏法宝:双下划线 _ _Dunder_ _
数据库·windows·microsoft
码农sssss6 小时前
1130 - Host ‘xxx.x.xx.xxx‘is not allowed to connect to this MySQL server
mysql
FungLeo8 小时前
安装和配置 Nginx 和 Mysql —— 一步一步配置 Ubuntu Server 的 NodeJS 服务器详细实录6
服务器·mysql·nginx
heart000_111 小时前
MySQL事务与锁机制详解:确保数据一致性的关键【MySQL系列】
数据库·mysql
一眼青苔11 小时前
MySQL 如何判断某个表中是否存在某个字段
数据库·mysql