【flink-cdc】flink-cdc 3版本debug启动pipeline任务,mysql-doris

官方文档
github仓库地址
Flink cdc debug调试动态变更表结构

经过测试使用,在启动任务配置Modify classpath添加jar的方式,容易出错classNotFoundException等等。

一、build project

flink-cdc版本:3.2.1

bash 复制代码
mvn clean package "-Dmaven.test.skip=true" "-Drat.skip=true" "-Dcheckstyle.skip"
# 当然install 也可以
mvn clean install "-Dmaven.test.skip=true" "-Drat.skip=true" "-Dcheckstyle.skip"

二、create module for test

在flink-cdc项目中新建一个module flink-cdc-test

将需要的flink cdc的connector依赖添加至pom

xml 复制代码
    <properties>        
        <flink.version>1.18.1</flink.version>  
        <maven.compiler.source>8</maven.compiler.source>  
        <maven.compiler.target>8</maven.compiler.target>  
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
    </properties>  
  
    <dependencies>        
        <dependency>  
            <groupId>org.apache.flink</groupId>  
            <artifactId>flink-table-common</artifactId>  
            <version>${flink.version}</version>  
            <scope>test</scope>  
        </dependency>  
  
        <!-- https://mvnrepository.com/artifact/org.apache.flink/flink-table-runtime -->  
        <dependency>  
            <groupId>org.apache.flink</groupId>  
            <artifactId>flink-table-runtime</artifactId>  
            <version>${flink.version}</version>  
            <scope>test</scope>  
        </dependency>  
  
        <!-- https://mvnrepository.com/artifact/org.apache.flink/flink-table-api-java-bridge -->  
        <dependency>  
            <groupId>org.apache.flink</groupId>  
            <artifactId>flink-table-api-java-bridge</artifactId>  
            <version>${flink.version}</version>  
            <scope>test</scope>  
        </dependency>  
  
        <!-- https://mvnrepository.com/artifact/org.apache.flink/flink-core -->  
        <dependency>  
            <groupId>org.apache.flink</groupId>  
            <artifactId>flink-core</artifactId>  
            <version>${flink.version}</version>  
            <scope>test</scope>  
        </dependency>  
  
        <!-- https://mvnrepository.com/artifact/org.apache.flink/flink-streaming-java -->  
        <dependency>  
            <groupId>org.apache.flink</groupId>  
            <artifactId>flink-streaming-java</artifactId>  
            <version>1.18.1</version>  
            <scope>test</scope>  
        </dependency>  
  
        <dependency>            
            <groupId>org.apache.flink</groupId>  
            <artifactId>flink-clients</artifactId>  
            <version>1.18.1</version>  
            <scope>test</scope>  
        </dependency>  
  
        <dependency>            
        <groupId>org.apache.flink</groupId>  
            <artifactId>flink-cdc-cli</artifactId>  
            <version>${project.version}</version>  
            <scope>test</scope>  
        </dependency>  
  
        <dependency>            
            <groupId>org.apache.flink</groupId>  
            <artifactId>flink-cdc-pipeline-connector-mysql</artifactId>  
            <version>${project.version}</version>  
            <scope>test</scope>  
        </dependency>  
  
        <dependency>            
            <groupId>org.apache.flink</groupId>  
            <artifactId>flink-cdc-pipeline-connector-kafka</artifactId>  
            <version>${project.version}</version>  
            <scope>test</scope>  
        </dependency>  
  
        <dependency>            
            <groupId>org.apache.flink</groupId>  
            <artifactId>flink-cdc-pipeline-connector-doris</artifactId>  
            <version>${project.version}</version>  
            <scope>test</scope>  
        </dependency>  
  
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->  
        <dependency>  
            <groupId>mysql</groupId>  
            <artifactId>mysql-connector-java</artifactId>  
            <version>8.0.27</version>  
        </dependency>  
    
    </dependencies>  

create pipeline yaml

创建flink cdc pipeline的配置文件mysql-to-doris.yaml

注意:drois的端口号不是9030,而是8030

yaml 复制代码
source:  
  type: mysql  
  name: MySQL-Source  
  hostname: 192.168.100.123 
  port: 3306  
  username: root  
  password: 123456  
  tables: test.student  
  server-id: 5401-5404  
  server-time-zone: UTC  
  
sink:  
  type: doris  
  name: Doris-Sink  
  fenodes: 192.168.101:8030
  username: root
  password: 123456  
  
  
pipeline:  
  name: MySQL to Doris Schema Evolution  
  parallelism: 1

create pipeline start entrypoint

测试类,需在src/test目录下:

java 复制代码
import org.apache.flink.cdc.cli.CliFrontend;  
import org.junit.jupiter.api.Test;  
  
import java.util.ArrayList;  
import java.util.List;  
  
public class MysqlPipelineTest {  
  
    @Test  
    public void testMysql() throws Exception {  
        List<String> args= new ArrayList<>();  
        args.add("D:\\flink-cdc-release-3.2.1\\flink-cdc-test\\pipelines\\mysql-to-doris.yaml");  
        args.add("--use-mini-cluster");  
        args.add("true");  
        CliFrontend.main(args.toArray(new String[0]));  
    }  
}

修改启动配置添加FLINK_HOME环境变量:

启动任务:

相关推荐
BD_Marathon5 小时前
【Flink】部署模式
java·数据库·flink
技术与健康6 小时前
LLM实践系列:利用LLM重构数据科学流程03- LLM驱动的数据探索与清洗
大数据·人工智能·重构
TDengine (老段)7 小时前
TDengine IDMP 应用场景:工业锅炉监控
大数据·数据库·物联网·信息可视化·时序数据库·tdengine
软件开发明哥8 小时前
BigData大数据应用开发学习笔记(06)实时检索--HBase
大数据
一只叫煤球的猫9 小时前
看到同事设计的表结构我人麻了!聊聊怎么更好去设计数据库表
后端·mysql·面试
杨荧9 小时前
基于Python的农作物病虫害防治网站 Python+Django+Vue.js
大数据·前端·vue.js·爬虫·python
遇见你的雩风10 小时前
【MySQL】CRUD基础详解
数据库·mysql
卖寂寞的小男孩11 小时前
spark数据缓存机制
大数据·缓存·spark
jiedaodezhuti12 小时前
Flink直接缓冲存储器异常解析与解决方案
大数据·flink
.Shu.12 小时前
Mysql InnoDB 底层架构设计、功能、原理、源码系列合集【四、事务引擎核心 - MVCC与锁机制】
数据库·mysql