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' -- 或者你所需的时区

);

相关推荐
码界筑梦坊3 小时前
基于Spark的抖音数据分析热度预测系统
大数据·信息可视化·数据分析·spark·毕业设计·个性化推荐
生信学习小达人4 小时前
arcgis10.8 Toolbox中没有找到conversion tools模块
大数据
Oo_Amy_oO5 小时前
Airflow+Spark/Flink vs. Kettle
大数据·flink·spark
后端小肥肠6 小时前
港大团队开源LightRAG:知识图谱+双层检索,复杂问答准确率飙升30%
大数据·人工智能·openai
计算机毕设定制辅导-无忧学长17 小时前
TDengine 权限管理与安全配置实战(二)
大数据·安全·tdengine
2401_8979300617 小时前
Kibana 连接 Elasticsearch(8.11.3)教程
大数据·elasticsearch·jenkins
计算机毕设定制辅导-无忧学长17 小时前
TDengine 快速上手:安装部署与基础 SQL 实践(一)
大数据·sql·tdengine
塔能物联运维18 小时前
塔能科技:精准节能,擎动工厂可持续发展巨轮
大数据·运维
今天我又学废了18 小时前
Spark,HDFS概述
大数据·hdfs·spark
青云交19 小时前
Java 大视界 -- 基于 Java 的大数据机器学习模型在图像识别中的迁移学习与模型优化(173)
大数据·迁移学习·图像识别·模型优化·deeplearning4j·机器学习模型·java 大数据