开发者社区 > 大数据与机器学习 > 实时计算 Flink > 正文

请问Flink CDC mysql2.4.0 的忽略无主键表 我看到这个参数··请问怎么设置?

问题1:请问Flink CDC mysql2.4.0 的忽略无主键表 我看到这个参数··请问怎么设置? scan.incremental.snapshot.chunk.key-column?我也刚刚看到代码部分了·
/** * The chunk key of table snapshot, captured tables are split into multiple chunks by the chunk * key column when read the snapshot of table. / public MySqlSourceConfigFactory chunkKeyColumn(Map<ObjectPath, String> chunkKeyColumns) { this.chunkKeyColumns.putAll(chunkKeyColumns); return this; } 问题2:我也刚刚看到代码部分了·
/
* * The chunk key of table snapshot, captured tables are split into multiple chunks by the chunk * key column when read the snapshot of table. */ public MySqlSourceConfigFactory chunkKeyColumn(Map<ObjectPath, String> chunkKeyColumns) { this.chunkKeyColumns.putAll(chunkKeyColumns); return this; }不过这样其实就相当于我无法预知 新增的无主键表。

展开
收起
cuicuicuic 2023-07-01 19:21:58 813 0
3 条回答
写回答
取消 提交回答
  • 在Flink CDC中,针对无主键表的忽略设置,您可以使用scan.incremental.snapshot.chunk.key-column参数进行配置。

    根据您提供的代码片段来看,chunkKeyColumn()方法用于设置表快照的块键(chunk key),从而将捕获的表拆分为多个块。这个参数允许您指定一个或多个列作为块键列,用于划分表的快照。

    具体配置步骤如下:

    1. 在Flink CDC的配置文件(如conf/flink-conf.yaml)中添加以下参数设置:       scan.incremental.snapshot.chunk.key-column: <column-names>        其中,<column-names>是您希望作为块键列的列名,可以是单个列或多个列,用逗号分隔。

    2. 重新启动Flink CDC任务以使配置生效。

    通过设置scan.incremental.snapshot.chunk.key-column可以将无主键的表自动拆分为多个块,并在捕获和读取表的快照时进行处理。

    需要注意的是,这种方式只能按照指定的块键进行拆分,对于新增的无主键表可能需要手动更新配置文件以添加新表的块键列。

    请确保您在配置文件中正确设置了参数并遵循了相应的语法规则。如果有进一步的问题,请参考Flink CDC的官方文档、社区讨论或寻求专业支持以获得更准确的帮助。

    2023-07-30 13:46:06
    赞同 展开评论 打赏
  • 北京阿里云ACE会长

    在 Flink CDC for MySQL 2.4.0 中,可以使用 scan.incremental.snapshot.chunk.key-column 参数来设置忽略无主键表。该参数用于指定表快照的分块键(chunk key)的列名,只有使用该列名作为快照分块键的表才会被捕获和同步。
    如果您想忽略无主键的表,可以将 scan.incremental.snapshot.chunk.key-column 设置为 NULL 或空字符串。这样,所有的表都将被忽略。
    以下是一个示例配置文件,其中 scan.incremental.snapshot.chunk.key-column 被设置为空字符串,以忽略无主键的表:
    stylus
    Copy

    Flink CDC for MySQL configuration file

    MySQL server connection configuration

    flink.cdc.source.connection-url = jdbc:mysql://localhost:3306/test?useSSL=false
    flink.cdc.source.username = root
    flink.cdc.source.password = 123456

    MySQL server binlog position

    flink.cdc.source.server-id = 1
    flink.cdc.source.binlog.filename = mysql-bin.000001
    flink.cdc.source.binlog.position = 4

    Table capture configuration

    flink.cdc.source.table-list = test.test_table
    flink.cdc.source.scan.incremental.snapshot.enabled = true
    flink.cdc.source.scan.incremental.snapshot.chunk.size = 100000
    flink.cdc.source.scan.incremental.snapshot.chunk.delay = 1000
    flink.cdc.source.scan.incremental.snapshot.chunk.key-column = ""
    需要注意的是,忽略无主键表可能会导致数据同步不完整,因为无主键表的数据更新可能无法被捕获和同步。因此,在设置 scan.incremental.s

    2023-07-30 11:29:16
    赞同 展开评论 打赏
  • 回答1:scan.incremental.snapshot.chunk.key-column 可以选择表的一列写入,有一些注意事项:1. 如果该列存在更新则只能保证at least once,2. 如果该列不存在索引,全量阶段会退化为表锁。,此回答整理自钉群“Flink CDC 社区”

    2023-07-01 19:31:14
    赞同 展开评论 打赏

实时计算Flink版是阿里云提供的全托管Serverless Flink云服务,基于 Apache Flink 构建的企业级、高性能实时大数据处理系统。提供全托管版 Flink 集群和引擎,提高作业开发运维效率。

相关产品

  • 实时计算 Flink版
  • 相关电子书

    更多
    搭建电商项目架构连接MySQL 立即下载
    搭建4层电商项目架构,实战连接MySQL 立即下载
    PolarDB MySQL引擎重磅功能及产品能力盛大发布 立即下载

    相关镜像