MySQL到Doris的StreamingETL实现(Flink CDC 3.0)

1 环境准备

1)安装FlinkCDC

shell 复制代码
[root@hadoop1 software]$ tar -zxvf flink-cdc-3.0.0-bin.tar.gz -C /opt/module/

2)拖入MySQL以及Doris依赖包

将flink-cdc-pipeline-connector-doris-3.0.0.jar以及flink-cdc-pipeline-connector-mysql-3.0.0.jar防止在FlinkCDC的lib目录下

2 同步变更

2)编写MySQL到Doris的同步变更配置文件

在FlinkCDC目录下创建job文件夹,并在该目录下创建同步变更配置文件

shell 复制代码
[root@hadoop1 flink-cdc-3.0.0]$ mkdir job/

[root@hadoop1 flink-cdc-3.0.0]$ cd job

[root@hadoop1 job]$ vim mysql-to-doris.yaml

 

source:

 type: mysql

 hostname: hadoop3

 port: 3306

 username: root

 password: "123456"

 tables: test.\.

 server-id: 5400-5404

 server-time-zone: UTC+8

 

sink:

 type: doris

 fenodes: hadoop1:7030

 username: root

 password: "123456"

 table.create.properties.light_schema_change: true

 table.create.properties.replication_num: 1

 

pipeline:

 name: Sync MySQL Database to Doris

 parallelism: 1

3)启动任务并测试

(1)开启Flink集群,注意:在Flink配置信息中打开CheckPoint

shell 复制代码
[root@hadoop3 flink-1.18.0]$ vim conf/flink-conf.yaml

添加如下配置信息

shell 复制代码
execution.checkpointing.interval: 5000

分发该文件至其他Flink机器并启动Flink集群

shell 复制代码
[root@hadoop3 flink-1.18.0]$ bin/start-cluster.sh

(2)开启Doris FE

shell 复制代码
[root@hadoop1 fe]$ bin/start_fe.sh

(3)开启Doris BE

shell 复制代码
[root@hadoop1 be]$ bin/start_be.sh

(4)在Doris中创建test数据库

shell 复制代码
[root@hadoop3 doris]$ mysql -uroot -p123456 -P9030 -hhadoop1

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or g.

Your MySQL connection id is 0

Server version: 5.7.99 Doris version doris-1.2.4-1-Unknown

 

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

 

mysql> create database test;

Query OK, 1 row affected (0.00 sec)

 

mysql> create database doris_test_route;

Query OK, 1 row affected (0.00 sec)

(5)启动FlinkCDC同步变更任务

shell 复制代码
[root@hadoop3 flink-cdc-3.0.0]$ bin/flink-cdc.sh job/mysql-to-doris.yaml

(6)刷新Doris中test数据库观察结果

(7)在MySQL的test数据中对应的几张表进行新增、修改数据以及新增列操作,并刷新Doris中test数据库观察结果

3 路由变更

1)编写MySQL到Doris的路由变更配置文件

shell 复制代码
source:

 type: mysql

 hostname: hadoop3

 port: 3306

 username: root

 password: "123456"

 tables: test_route.\.

 server-id: 5400-5404

 server-time-zone: UTC+8

 

sink:

 type: doris

 fenodes: hadoop1:7030

 benodes: hadoop1:7040

 username: root

 password: "123456"

 table.create.properties.light_schema_change: true

 table.create.properties.replication_num: 1

 

route:

 - source-table: test_route.t1

  sink-table: doris_test_route.doris_t1

 - source-table: test_route.t2

  sink-table: doris_test_route.doris_t1

 - source-table: test_route.t3

  sink-table: doris_test_route.doris_t3

 

pipeline:

 name: Sync MySQL Database to Doris

 parallelism: 1

2)启动任务并测试

she 复制代码
[root@hadoop3 flink-cdc-3.0.0]$ bin/flink-cdc.sh job/mysql-to-doris-route.yaml

3)刷新Doris中test_route数据库观察结果

4)在MySQL的test_route数据中对应的几张表进行新增、修改数据操作,并刷新Doris中doris_test_route数据库观察结果

相关推荐
CHICX12297 分钟前
【Hadoop】改一下core-site.xml和hdfs-site.xml配置就可以访问Web UI
xml·大数据·hadoop
权^41 分钟前
MySQL--聚合查询、联合查询、子查询、合并查询(上万字超详解!!!)
大数据·数据库·学习·mysql
bin91535 小时前
【EXCEL数据处理】000010 案列 EXCEL文本型和常规型转换。使用的软件是微软的Excel操作的。处理数据的目的是让数据更直观的显示出来,方便查看。
大数据·数据库·信息可视化·数据挖掘·数据分析·excel·数据可视化
极客先躯8 小时前
Hadoop krb5.conf 配置详解
大数据·hadoop·分布式·kerberos·krb5.conf·认证系统
2301_7869643610 小时前
3、练习常用的HBase Shell命令+HBase 常用的Java API 及应用实例
java·大数据·数据库·分布式·hbase
matlabgoodboy11 小时前
“图像识别技术:重塑生活与工作的未来”
大数据·人工智能·生活
happycao12312 小时前
Flink 03 | 数据流基本操作
大数据·flink
Neituijunsir12 小时前
2024.09.22 校招 实习 内推 面经
大数据·人工智能·算法·面试·自动驾驶·汽车·求职招聘
BD_Marathon14 小时前
设置hive本地模式
数据仓库·hive·hadoop
Data 31714 小时前
Hive数仓操作(十一)
大数据·数据库·数据仓库·hive·hadoop