Flink CDC (session模式)

1、

复制代码
# Start YARN session
./bin/yarn-session.sh --detached

2、配置文件:

复制代码
rest.bind-port: {{REST_PORT}}
rest.address: {{NODE_IP}}
execution.target: yarn-session
yarn.application.id: {{YARN_APPLICATION_ID}}

3、mysql-doris.yml

复制代码
source:
 type: mysql
 hostname: localhost
 port: 3306
 username: root
 password: 123456
 tables: app_db.\.*
 server-id: 5400-5404
 server-time-zone: UTC

sink:
 type: doris
 fenodes: 127.0.0.1:8030
 username: root
 password: ""

pipeline:
 name: Sync MySQL Database to Doris
 parallelism: 2

4、运行测试:

复制代码
./bin/flink-cdc.sh mysql-to-doris.yaml

5、相关问题:

1、Caused by: java.lang.ClassCastException: cannot assign instance of com.starrocks.connector.flink.catalog.StarRocksCatalog to field org.apache.flink.cdc.connectors.starrocks.sink.StarRocksMetadataApplier.catalog of type com.starrocks.connector.flink.catalog.StarRocksCatalog in instance of org.apache.flink.cdc.connectors.starrocks.sink.StarRocksMetadataApplier

解决方案:

classloader.resolve-order: parent-first

2、

Caused by: org.apache.flink.runtime.JobException: Cannot instantiate the coordinator for operator Source: Flink CDC Event Source: mysql -> SchemaOperator -> PrePartition

at org.apache.flink.runtime.executiongraph.ExecutionJobVertex.initialize(ExecutionJobVertex.java:229)

at org.apache.flink.runtime.executiongraph.DefaultExecutionGraph.initializeJobVertex(DefaultExecutionGraph.java:914)

at org.apache.flink.runtime.executiongraph.ExecutionGraph.initializeJobVertex(ExecutionGraph.java:218)

at org.apache.flink.runtime.executiongraph.DefaultExecutionGraph.initializeJobVertices(DefaultExecutionGraph.java:896)

at org.apache.flink.runtime.executiongraph.DefaultExecutionGraph.attachJobGraph(DefaultExecutionGraph.java:852)

at org.apache.flink.runtime.executiongraph.DefaultExecutionGraphBuilder.buildGraph(DefaultExecutionGraphBuilder.java:207)

at org.apache.flink.runtime.scheduler.DefaultExecutionGraphFactory.createAndRestoreExecutionGraph(DefaultExecutionGraphFactory.java:163)

at org.apache.flink.runtime.scheduler.SchedulerBase.createAndRestoreExecutionGraph(SchedulerBase.java:365)

at org.apache.flink.runtime.scheduler.SchedulerBase.<init>(SchedulerBase.java:210)

at org.apache.flink.runtime.scheduler.DefaultScheduler.<init>(DefaultScheduler.java:136)

at org.apache.flink.runtime.scheduler.DefaultSchedulerFactory.createInstance(DefaultSchedulerFactory.java:152)

at org.apache.flink.runtime.jobmaster.DefaultSlotPoolServiceSchedulerFactory.createScheduler(DefaultSlotPoolServiceSchedulerFactory.java:119)

at org.apache.flink.runtime.jobmaster.JobMaster.createScheduler(JobMaster.java:371)

at org.apache.flink.runtime.jobmaster.JobMaster.<init>(JobMaster.java:348)

at org.apache.flink.runtime.jobmaster.factories.DefaultJobMasterServiceFactory.internalCreateJobMasterService(DefaultJobMasterServiceFactory.java:123)

at org.apache.flink.runtime.jobmaster.factories.DefaultJobMasterServiceFactory.lambdacreateJobMasterService0(DefaultJobMasterServiceFactory.java:95)

at org.apache.flink.util.function.FunctionUtils.lambdauncheckedSupplier4(FunctionUtils.java:112)

... 4 more

Caused by: java.lang.NoClassDefFoundError: org/apache/flink/cdc/runtime/typeutils/EventTypeInfo

at java.lang.Class.getDeclaredFields0(Native Method)

at java.lang.Class.privateGetDeclaredFields(Class.java:2583)

解决方案:

cp /BigData/run/flink-cdc/lib/flink-cdc-dist-3.1.0.jar /BigData/run/flink/lib/

3、问题3

Caused by: org.apache.flink.table.api.ValidationException: The MySQL server has a timezone offset (28800 seconds ahead of UTC) which does not match the configured timezone UTC. Specify the right server-time-zone to avoid inconsistencies for time-related fields.

解决方案1:

jdbc:mysql://hostname:port/database?serverTimezone=UTC

解决方案2:

SET table.local-time-zone = 'Asia/Shanghai'; -- 或者你所需的时区

解决方案3:

CREATE TABLE my_table (

...

) WITH (

'connector' = 'mysql-cdc',

'hostname' = 'localhost',

'port' = '3306',

...

'server-time-zone' = 'Asia/Shanghai' -- 或者你所需的时区

);

相关推荐
乐迪信息几秒前
乐迪信息:AI防爆摄像机识别船舶违规明火作业
大数据·人工智能·安全·计算机视觉·目标跟踪
D愿你归来仍是少年11 分钟前
Apache Spark 第 3 章:核心概念 RDD / DataFrame
大数据·spark·apache
易连EDI—EasyLink27 分钟前
Odette OFTP2 Group1/2/3深度解读:PDX XML能力划分与选型指南
大数据·电子数据交换·as2·易连edi·oftp2
大榕树信息科技41 分钟前
高效动环监控赋能机房环境智能管理与数据可视化
大数据·网络·数据库·人工智能·信息可视化
GlobalInfo44 分钟前
全球户外WiFi智能插头市场份额、规模、技术研究报告2026
大数据·网络·人工智能
于先生吖1 小时前
Java 智慧社区本地生活系统:上门服务 + 商城模块完整开发
java·大数据·生活
岁岁种桃花儿1 小时前
Flink从入门到上天系列第二十二篇:Flink中通过UI查看检查点
大数据·ui·flink
JZC_xiaozhong1 小时前
医疗器械行业供应商主数据管理:多视角下的破局与重构
大数据·数据库·重构·数据分析·mdm·主数据管理·数据集成与应用集成
Web3_Daisy1 小时前
Flap怎么玩?低门槛 Meme 币的发射与链上策略
大数据·人工智能·web3·区块链·比特币
石逸凡1 小时前
AI时代企业数据架构转型趋势一:分析数据集上移
大数据·人工智能·架构