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

Flink CDC这个参数代码里不支持?

Flink CDC这个参数代码里不支持?image.png
image.png
read权限是有的image.png

展开
收起
真的很搞笑 2023-12-04 07:47:26 32 0
3 条回答
写回答
取消 提交回答
  • 这是增量快照的,你导包不对 ,此回答整理自钉群“Flink CDC 社区”

    2023-12-05 09:01:46
    赞同 展开评论 打赏
  • 面对过去,不要迷离;面对未来,不必彷徨;活在今天,你只要把自己完全展示给别人看。

    Flink CDC不支持scan.startup.mode参数。

    2023-12-04 14:21:18
    赞同 展开评论 打赏
  • Flink CDC 支持的参数代码如下:

    import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
    import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
    import org.apache.flink.table.catalog.hive.HiveCatalog;
    import org.apache.flink.table.descriptors.Schema;
    import org.apache.flink.table.descriptors.TableDescriptor;
    import org.apache.flink.table.descriptors.connectors.DebeziumCatalogConnector;
    import org.apache.flink.table.descriptors.types.RowType;
    
    public class FlinkCDCExample {
        public static void main(String[] args) throws Exception {
            StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
            StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);
    
            HiveCatalog hiveCatalog = new HiveCatalog("default", "localhost", 31010, null, null);
            tableEnv.registerCatalog("hive", hiveCatalog);
            tableEnv.useCatalog("hive");
    
            TableDescriptor tableDescriptor = TableDescriptor.builder()
                    .name("your_table_name")
                    .schema(Schema.builder().field("id", DataTypes.BIGINT()).field("name", DataTypes.STRING()).build())
                    .connector(DebeziumCatalogConnector.newBuilder()
                            .type("mysql")
                            .version("8.0.26")
                            .hostname("your_mysql_host")
                            .port(3306)
                            .username("your_mysql_username")
                            .password("your_mysql_password")
                            .databaseName("your_mysql_database")
                            .tableNamePrefix("your_mysql_table_prefix")
                            .build())
                    .build();
    
            tableEnv.createTemporaryView("your_table_name", tableDescriptor);
    
            tableEnv.toAppendStream(tableDescriptor, RowType.of(DataTypes.BIGINT(), DataTypes.STRING()))
                    .print();
    
            env.execute("Flink CDC Example");
        }
    }
    

    请将上述代码中的 your_table_nameyour_mysql_hostyour_mysql_usernameyour_mysql_passwordyour_mysql_databaseyour_mysql_table_prefix 替换为实际的值。

    2023-12-04 11:52:24
    赞同 展开评论 打赏

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

相关产品

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

    更多
    Flink CDC Meetup PPT - 龚中强 立即下载
    Flink CDC Meetup PPT - 王赫 立即下载
    Flink CDC Meetup PPT - 覃立辉 立即下载