【问题标题】:Unable to run a JDBC Source connector with Confluent REST API无法使用 Confluent REST API 运行 JDBC 源连接器
【发布时间】:2018-10-25 09:23:03
【问题描述】:

我想使用 Kafka Connect REST API 运行 JDBC 源连接器。 尽管使用以下属性文件可以完美运行单机模式:

name=source-mysql-test
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
tasks.max=1

connection.url=jdbc:mysql://localhost:3306/kafka
connection.user=myuser
connection.password=mypass


table.whitelist=MY_TABLE

# Pull all rows based on timestamp
mode=timestamp
timestamp.column.name=ROWVERSION
validate.non.null=false

# The Kafka topic will be made up of this prefix, plus the table name.
topic.prefix=MYSQL-

table.types=TABLE,VIEW
poll.interval.ms=1000

我无法使用 REST API 运行连接器。 这是电话:

curl -X POST -H "Content-Type: application/json" --data '{"name": "source-mysql-test", "config": {"connector.class":"io.confluent.connect.jdbc.JdbcSourceConnector", "tasks.max":"1", "connection.url":"jdbc:mysql://localhost:3306/kafka","connection.user":"myuser","connection.password":"mypass", "table.whitelist":"MY_TABLE", "mode":"timestamp", "timestamp.column.name":"ROWVERSION", "validate.non.null":"false", "topic.prefix":"MYSQL-", "table.types":"TABLE,VIEW", "poll.interval.ms":"1000" }}' http://localhost:8083/connectors

下面是回复:

{
  "error_code": 400,
  "message": "Connector configuration is invalid and contains the following 2 error(s):\nInvalid value com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. for configuration Couldn't open connection to jdbc:mysql://localhost:3306/kafka\nInvalid value com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. for configuration Couldn't open connection to jdbc:mysql://localhost:3306/kafka\nYou can also find the above list of errors at the endpoint `/{connectorType}/config/validate`"
}

在过去,我使用 REST API 来运行 JDBC 接收器连接器没有任何问题!

以下是可用的连接器插件:

> ls /usr/share/java/kafka-connect-jdbc/
common-utils-4.1.0.jar        mysql-connector-java-5.1.46.jar  uber-restavro-1.0-SNAPSHOT.jar
jline-0.9.94.jar              netty-3.10.5.Final.jar          
kafka-connect-jdbc-4.1.0.jar  postgresql-9.4-1206-jdbc41.jar   zkclient-0.10.jar
log4j-1.2.17.jar              slf4j-api-1.7.25.jar             zookeeper-3.4.10.jar
mssql-jdbc-6.2.2.jre8.jar     sqlite-jdbc-3.8.11.2.jar

【问题讨论】:

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


    【解决方案1】:

    问题似乎是 JDBC 连接器与 MySQL 8 的兼容性。 我已将 MySQL Connector/J 从 5.1.46 升级到 8.0.11,问题已得到解决。

    【讨论】:

      【解决方案2】:
      com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: 
      Could not create connection to database server
      

      Kafka Connect 无法连接到您的 MySQL 机器。

      【讨论】:

      • 如何解释 Kafka Connect 在独立模式下可以连接 MySQL?
      • 它是否在不同的机器上运行?您是否使用相同的 JDBC 驱动程序?错误非常明确:Couldn't open connection to jdbc:mysql://localhost:3306/kafka
      • 是的,MySQL 和 Kafka 在同一台机器上运行,并且独立模式和 REST API 调用都在同一台机器上执行。
      • 另外,对 REST API 的其他调用运行没有任何问题,并且能够连接到数据库。
      • 好的,那么连接到数据库的REST调用和这个的REST调用有什么区别?
      猜你喜欢
      • 1970-01-01
      • 2019-06-11
      • 1970-01-01
      • 2021-08-30
      • 2021-08-25
      • 2018-10-01
      • 1970-01-01
      • 2020-02-05
      • 1970-01-01
      相关资源
      最近更新 更多