【发布时间】:2019-11-13 05:55:10
【问题描述】:
我有一个旧数据库,它的主键列是字符串(是的,我知道)。我想使用 JDBC kafka Source Connector 将 increment 从 postgres DB 转储到 kafka 主题中
下面是我尝试重现问题
create table test(
id varchar(20) primary key,
name varchar(10)
);
INSERT INTO test(
id, name)
VALUES ('1ab', 't'),
('2ab', 't'),
('3ab', 't')
我的配置
{"name" : "test_connector",
"config" : {
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"connection.url": "jdbc:postgresql://12.34.5.6:5432/",
"connection.user": "user",
"connection.password": "password",
"key.converter": "org.apache.kafka.connect.storage.StringConverter",
"topic.prefix": "incre_",
"mode": "incrementing",
"value.converter": "io.confluent.connect.avro.AvroConverter",
"query" :"SELECT cast(replace(id, 'ab','') as integer) as id , name from test ORDER BY id ASC",
"incrementing.column.name":"id",
"value.converter.schema.registry.url": "http://schema-registry_url.com",
"key.converter.schema.registry.url": "http://schema-registry_url.com",
"offset.flush.timeout.ms": 2000,
}
}
在我发布配置后,当我执行 HTTP curl 时,状态为 RUNNING。当我检查它时,工人的日志中也没有错误日志
当我尝试做一个控制台消费者时,kafka 主题中也没有数据
我还尝试了其他几种组合,例如添加"table.whitelist": "test"。
我尝试的另一件事是关注这两个链接
https://rmoff.net/2018/05/21/kafka-connect-and-oracle-data-types/
https://www.confluent.io/blog/kafka-connect-deep-dive-jdbc-source-connector 但无济于事,即使是像 SELECT * from (SELECT id, name from test where ...) 这样建议的聪明技巧
【问题讨论】:
标签: jdbc apache-kafka apache-kafka-connect