kafka连接器jdbc-sink语法错误最后

时间:2019-04-30 06:47:05

标签: postgresql jdbc apache-kafka docker-compose debezium

我对此拱门有一个关于jdbc-sink的问题。

  

postgres1 ---> kafka ---> postgres2

生产者工作正常,但消费者有错误:

  

connect_1 | org.apache.kafka.connect.errors.RetriableException:   java.sql.SQLException:java.sql.BatchUpdateException:批处理条目0   在冲突(“ id”)上插入“ customers”(“ id”)值(1)进行更新   SET被中止:错误:输入connect_1末尾的语法错误|
  位置:77调用getNextException以查看批处理中的其他错误。

这是我的source.json

{
"name": "src-table",
"config": {
    "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
    "tasks.max": "1",
    "database.hostname": "postgres1_container",
    "database.port": "5432",
    "database.user": "postgres",
    "database.password": "postgres",
    "database.dbname": "postgres",
    "database.whitelist": "postgres",
    "database.server.name": "postgres1",
    "database.history.kafka.bootstrap.servers": "kafka:9092",
    "database.history.kafka.topic": "schema-changes.inventory",
    "transforms": "route",
    "transforms.route.type": "org.apache.kafka.connect.transforms.RegexRouter",
    "transforms.route.regex": "([^.]+)\\.([^.]+)\\.([^.]+)",
    "transforms.route.replacement": "$3"
}

这是我的jdbc-sink.json

{
    "name": "jdbc-sink",
    "config": {
        "connector.class": "io.confluent.connect.jdbc.JdbcSinkConnector",
        "tasks.max": "1",
        "topics": "customers",
        "connection.url": "jdbc:postgresql://postgres2_container:5432/postgres?user=postgres&password=postgres",
        "transforms": "unwrap",
        "transforms.unwrap.type": "io.debezium.transforms.UnwrapFromEnvelope",
        "auto.create": "true",
        "insert.mode": "upsert",
        "pk.fields": "id",
        "pk.mode": "record_value"
    }
}

debezium / zookeeper:0.9

debezium / kafka:0.9

debezium / postgres:9.6

debezium / connect:0.9

PostgreSQL JDBC驱动程序42.2.5

Kafka Connect JDBC 5.2.1

我试图降级jdbc驱动程序和融合的kafka连接,但仍然有相同的错误

1 个答案:

答案 0 :(得分:0)

解决,当我在postgres1中创建表时出现问题,因为我没有将id设置为PK值