在Kafka Connect中找不到适用于jdbc:mysql的驱动程序

时间:2018-08-09 03:39:22

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

connect-standalone.properties

connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
bootstrap.servers=10.33.62.20:9092,10.33.62.110:9092,10.33.62.200:9092
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter.schemas.enable=true
value.converter.schemas.enable=true

offset.storage.file.filename=/tmp/connect.offsets
offset.flush.interval.ms=10000
plugin.path=/grid/1/mukul/confluent-5.0.0/share/java

source-sqlite.properties

name=test-source-sqlite-jdbc-autoincrement
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
tasks.max=5

connection.url=jdbc:mysql://10.32.177.178:3306/test&user=xxxx&password=xxxxx

table.whitelist=banner_hourly_statistics_v2

group.id=test-mysql-kafka
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter

config.storage.topic=demo-1-distributed-config
offset.storage.topic=demo-1-distributed-offset
status.storage.topic=demo-1-distributed-status

bootstrap.servers=10.33.62.20:9092,10.33.62.110:9092,10.33.62.200:9092
mode=bulk
#incrementing.column.name=id
topic.prefix=test-sqlite-jdbc-

CMD:connect-standalone /grid/1/mukul/confluent-5.0.0/etc/kafka/connect-standalone.properties /grid/1/mukul/confluent-5.0.0/etc/kafka-connect-jdbc/source-quickstart-sqlite.properties

在启动日志中,它清楚地显示了正在加载JDBC连接器:

[2018-08-09 06:59:30,072] INFO Loading plugin from: /grid/1/mukul/confluent-5.0.0/share/java/kafka-connect-jdbc (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader:218)
[2018-08-09 06:59:30,133] INFO Registered loader: PluginClassLoader{pluginLocation=file:/grid/1/mukul/confluent-5.0.0/share/java/kafka-connect-jdbc/} (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader:241)
[2018-08-09 06:59:30,133] INFO Added plugin 'io.confluent.connect.jdbc.JdbcSinkConnector' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader:170)
[2018-08-09 06:59:30,133] INFO Added plugin 'io.confluent.connect.jdbc.JdbcSourceConnector' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader:170)

但是它失败,但出现以下异常:

Invalid value java.sql.SQLException: No suitable driver found for jdbc:mysql://10.32.177.178:3306/test&user=xxxx&password=xxxx for configuration Couldn't open connection to jdbc:mysql://10.32.177.178:3306/test&user=xxxx&password=xxx
Invalid value java.sql.SQLException: No suitable driver found for jdbc:mysql://10.32.177.178:3306/test&user=xxxx&password=xxxx for configuration Couldn't open connection to jdbc:mysql://10.32.177.178:3306/test&user=xxxx&password=xxxx
You can also find the above list of errors at the endpoint `/{connectorType}/config/validate`
    at org.apache.kafka.connect.util.ConvertingFutureCallback.result(ConvertingFutureCallback.java:79)
    at org.apache.kafka.connect.util.ConvertingFutureCallback.get(ConvertingFutureCallback.java:66)
    at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:110)

也尝试过更改插件目录,但是没有用。尝试将融合的share / *也移动到/ usr / share / java,但是也没有用。

2 个答案:

答案 0 :(得分:1)

  1. 从以下网址下载JAR:https://dev.mysql.com/downloads/connector/j/5.1.html

  2. 放置在插件目录中

  3. 运行连接

它将开始从MySql中提取数据。

答案 1 :(得分:0)

可能有点晚了。当我使用 kafka jdbc 连接器连接 DB2 时,我遇到了同样的“找不到驱动程序......”的问题。

第一种可能的解决方案:

我通过将 DB2 驱动程序放置在 jdbc-connector 所在的确切位置解决了这个问题。 与 Kafka 连接:

find / -name kafka-connect-jdbc\*.jar

从上述命令中找到位置后,将 DB2 jar 复制到该位置:

cp {your DB2 jar location}/db2.jar {copy the location from 'find' command}

示例

cp /Download/db2.jar /Users/share/java/kafka-connect-java/

重启 kafka-connect,它会选择 DB2 驱动

第二种可能的解决方案:

下载 jt400 jar (jdk-8) 并将其放在其他 jdbc 驱动程序(DB2、SQL 等)旁边

快乐编码:)