【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环境变量:

启动任务:

相关推荐
秦老师Q9 分钟前
php入门教程(超详细,一篇就够了!!!)
开发语言·mysql·php·db
躺柒1 小时前
读数字时代的网络风险管理:策略、计划与执行04风险指引体系
大数据·网络·信息安全·数字化·网络管理·网络风险管理
橘子131 小时前
MySQL用户管理(十三)
数据库·mysql
Dxy12393102161 小时前
MySQL如何加唯一索引
android·数据库·mysql
我真的是大笨蛋1 小时前
深度解析InnoDB如何保障Buffer与磁盘数据一致性
java·数据库·sql·mysql·性能优化
怣501 小时前
MySQL数据检索入门:从零开始学SELECT查询
数据库·mysql
人道领域2 小时前
javaWeb从入门到进阶(SpringBoot事务管理及AOP)
java·数据库·mysql
独自归家的兔2 小时前
从 “局部凑活“ 到 “全局最优“:AI 规划能力的技术突破与产业落地实践
大数据·人工智能
海域云-罗鹏2 小时前
国内公司与英国总部数据中心/ERP系统互连,SD-WAN专线实操指南
大数据·数据库·人工智能
千寻技术帮3 小时前
10404_基于Web的校园网络安全防御系统
网络·mysql·安全·web安全·springboot