连接器配置不包含连接器类型

问题描述 投票:0回答:2

我正在尝试使用 JDBC Connector 连接到集群上的 PostgreSQL 数据库(该数据库不是由集群直接管理)。

我一直在使用以下命令调用 Kafka Connect:

connect-standalone.sh worker.properties jdbc-connector.properties

这是

worker.properties
文件的内容:

class=io.confluent.connect.jdbc.JdbcSourceConnector
name=test-postgres-1
tasks.max=1

internal.key.converter=org.apache.kafka.connect.json.JsonConverter
internal.value.converter=org.apache.kafka.connect.json.JsonConverter
internal.key.converter.schemas.enable=false
internal.value.converter.schemas.enable=false

offset.storage.file.filename=/home/user/offest
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter=org.apache.kafka.connect.json.JsonConverter

connection.url=jdbc:postgresql://database-server.url:port/database?user=user&password=password

这就是

jdbc-connector.properties
的内容:

mode=incrementing
incrementing.column.name=id
topic.prefix=test-postgres-jdbc-

当我尝试使用上述命令启动连接器时,它崩溃并出现以下错误:

[2018-04-16 11:39:08,164] ERROR Failed to create job for jdbc.properties (org.apache.kafka.connect.cli.ConnectStandalone:88)
[2018-04-16 11:39:08,166] ERROR Stopping after connector error (org.apache.kafka.connect.cli.ConnectStandalone:99)
java.util.concurrent.ExecutionException: org.apache.kafka.connect.runtime.rest.errors.BadRequestException: Connector config {mode=incrementing, incrementing.column.name=pdv, topic.prefix=test-postgres-jdbc-} contains no connector type
    at org.apache.kafka.connect.util.ConvertingFutureCallback.result(ConvertingFutureCallback.java:80)
    at org.apache.kafka.connect.util.ConvertingFutureCallback.get(ConvertingFutureCallback.java:67)
    at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:96)
Caused by: org.apache.kafka.connect.runtime.rest.errors.BadRequestException: Connector config {mode=incrementing, incrementing.column.name=id, topic.prefix=test-postgres-jdbc-} contains no connector type
    at org.apache.kafka.connect.runtime.AbstractHerder.validateConnectorConfig(AbstractHerder.java:233)
    at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.putConnectorConfig(StandaloneHerder.java:158)
    at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:93)

注意到导致错误的连接器仅显示来自

jdbc-connector.properties
的信息后,我尝试将两个文件合并在一起,但随后命令突然终止(不创建主题或偏移文件)并显示以下输出:

[SLF4J infos...]
[2018-04-16 11:48:54,620] INFO Usage: ConnectStandalone worker.properties connector1.properties [connector2.properties ...] (org.apache.kafka.connect.cli.ConnectStandalone:59)
apache-kafka apache-kafka-connect confluent-platform
2个回答
3
投票

您需要将大部分属性放在

jdbc-connector.properties
中,而不是
worker.properties
中。请参阅 https://docs.confluence.io/current/connect/connect-jdbc/docs/source_config_options.html 以获取连接器配置中的配置选项的完整列表(在示例中为
jdbc-connector.properties
)。

试试这个:

  • worker.properties
    :

    internal.key.converter=org.apache.kafka.connect.json.JsonConverter
    internal.value.converter=org.apache.kafka.connect.json.JsonConverter
    internal.key.converter.schemas.enable=false
    internal.value.converter.schemas.enable=false
    
    offset.storage.file.filename=/home/user/offest
    value.converter=org.apache.kafka.connect.json.JsonConverter
    key.converter=org.apache.kafka.connect.json.JsonConverter
    
  • jdbc-connector.properties
    :

    class=io.confluent.connect.jdbc.JdbcSourceConnector
    name=test-postgres-1
    tasks.max=1
    
    mode=incrementing
    incrementing.column.name=id
    topic.prefix=test-postgres-jdbc-
    
    connection.url=jdbc:postgresql://database-server.url:port/database?user=user&password=password
    

您可以在此处查看 Kafka Connect 的更多示例:


0
投票

对我来说,我使用源属性作为 .JSON 文件,后来我将其更改为 .property 文件并工作。如果您已经使用 .property 文件,请检查以下内容

  1. 确保在 connect-standalone/connect-distribured 属性文件中正确设置 plugin.path。如果您有多个文件夹,请将它们以逗号分隔。
  2. 确保java版本兼容性
  3. 确保 kafka-connector 插件兼容性。
© www.soinside.com 2019 - 2024. All rights reserved.