flink-cdc同步数据到doris中_flink cdc doris
1 创建数据库和表
1.1 数据库脚本
这样直接创建数据库是有问题,因为后面发现superset连接使用doris://root:123456@10.101.12.82:9030/internal.eayc?charset=utf8mb4
-- 创建数据库eayccreate database if not exists ods_eayc;-- 创建数据表
2 数据同步
2.1 flnk-cdc
参考Flink CDC实时同步MySQL到Doris
Flink CDC 概述
2.1.1 最简单的单表同步
从下面的yml脚本可以看到,并没有doris中创建eayc_user表,应该是flink-cdc自动创建的。
#Mysql的参数配置source: type: mysql hostname: 10.101.10.11 port: 3306 username: flink password: 123456 tables: eayc.eayc_user server-id: 5400 # server-time-zone: UTC#Doris的参数配置sink: type: doris fenodes: 10.101.11.2:8030,10.101.11.2:8030,10.101.11.3:8030 username: root password: 123456 table.create.properties.light_schema_change: true table.create.properties.replication_num: 1route: - source-table: eayc.eayc_user sink-table: ods_eayc.eayc_userpipeline: name: eayc to doris parallelism: 1
注意连接mysql的server-id的要唯一,否则提示下面的错误
A slave with the same server_uuid/server_id as this slave has connected to the master...The \'server-id\' in the mysql cdc connector should be globally unique, but conflicts happen now.
进入到flink的界面查看到错误日志,任务执行失败。下面报的错是mysql时区与flink配置不匹配。现在改生产库影响未知,不敢动,于是去掉server-time-zone: UTC设置。重新执行任务。
此时任务可以正常执行了,数据也可以正常过来了。因为flink-cdc是根据binlog,因此mysql变更,doris中的数据也实时更新过来。
2.1.2 多表同步
如下配置