【问题标题】:I want to load data to multiple tables from multiple topics using kafka-connect我想使用 kafka-connect 从多个主题将数据加载到多个表中
【发布时间】:2021-09-02 22:47:35
【问题描述】:

我想使用 kafka connect 将多个表数据从 oracle 加载到 postgres

这是我正在使用的源配置:-

curl -i -X PUT http://localhost:8083/connectors/src_1/config \
 -H "Content-Type: application/json" \
 -d '{
 "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
 "connection.url":"jdbc:oracle:thin:@//localhost:1521/db",
 "connection.user":"<user>",
 "connection.password":"<psswd>",
 "mode":"bulk",
 "table.whitelist":"EMP,CUS",
 "poll.interval.ms":7200000,
 "quote.sql.identifiers":"never"
 }'

通过上述配置,我可以创建两个名为“EMP”和“CUS”的主题。现在,我想将这些数据从主题加载到已在 postgres 中创建的各个表中。

这是我的接收器配置:-

curl -X PUT http://localhost:8083/connectors/tgt_1/config \
-H "Content-Type: application/json" \
-d '{
 "connector.class": "io.confluent.connect.jdbc.JdbcSinkConnector",
 "connection.url":"jdbc:postgresql://localhost:5432/postgres",
 "connection.user":"<user>",
 "connection.password":"<passwd>",
 "tasks.max" : "1",
 "topics":"CUS,EMP",
 "insert.mode":"insert",
 "quote.sql.identifiers":"never"
}'

使用上述配置,我遇到了一个错误,称为不匹配的表或自动创建被禁用。但是当我尝试创建单独的接收器连接器并使用表名设置属性table.name.format 时小写它工作正常。

所以,我尝试在table.whitelist 中以较小的大小写提供表名,以便以较小的大小写创建主题,并且可以与目标表名匹配。但是,源连接器既不抛出错误也不运行任务。

谁能为我的问题提供一个合适的解决方案。 谢谢!

【问题讨论】:

    标签: apache-kafka apache-kafka-connect confluent-platform


    【解决方案1】:

    我猜您的 PostgreSQL 接收器表名称是小写的(cusemp)并且它们不等于主题名称(CUSEMP)。 Kafka Connect JDBC 连接器usesgetTables() 方法来检查表是否存在,其中tableNamePattern 参数区分大小写(根据文档:must match the table name as it is stored in the database)。

    您可以使用从Kafka Connect Common Transformations 转换而来的ChangeTopicCase。另一种选择是将接收器表重命名为大写。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-04
      • 2020-12-08
      • 2021-10-23
      • 2019-08-13
      • 1970-01-01
      • 2021-11-16
      • 1970-01-01
      • 2021-06-26
      相关资源
      最近更新 更多