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

启动任务:

相关推荐
月光水岸New2 小时前
Ubuntu 中建的mysql数据库使用Navicat for MySQL连接不上
数据库·mysql·ubuntu
我爱松子鱼2 小时前
mysql之规则优化器RBO
数据库·mysql
人间打气筒(Ada)4 小时前
MySQL主从架构
服务器·数据库·mysql
和道一文字yyds4 小时前
MySQL 中的索引数量是否越多越好?为什么?如何使用 MySQL 的 EXPLAIN 语句进行查询分析?MySQL 中如何进行 SQL 调优?
数据库·sql·mysql
大数据追光猿5 小时前
Python应用算法之贪心算法理解和实践
大数据·开发语言·人工智能·python·深度学习·算法·贪心算法
人类群星闪耀时6 小时前
物联网与大数据:揭秘万物互联的新纪元
大数据·物联网·struts
哆木6 小时前
排查生产sql查询缓慢
数据库·sql·mysql
book01218 小时前
MySql数据库运维学习笔记
运维·数据库·mysql
纠结哥_Shrek8 小时前
Oracle和Mysql的区别
数据库·mysql·oracle
极客先躯8 小时前
说说高级java每日一道面试题-2025年2月13日-数据库篇-请说说 MySQL 数据库的锁 ?
java·数据库·mysql·数据库的锁·模式分·粒度分·属性分