kafka-connect-jdbc : SQLException: No suitable driver only when using distributed mode

家住魔仙堡 提交于 2020-01-17 01:24:08

问题


We have successfully used mySQL - kafka data ingestion using jdbc standalone connector but now facing issue in using the same in distributed mode (as kafka connect service ).

connect-distributed.properties file-

bootstrap.servers=IP1:9092,IP2:9092
group.id=connect-cluster
key.converter.schemas.enable=true
value.converter.schemas.enable=true
offset.storage.topic=connect-offsets
offset.storage.replication.factor=2
config.storage.topic=connect-configs
config.storage.replication.factor=2
status.storage.topic=connect-status
status.storage.replication.factor=2
offset.flush.interval.ms=10000
plugin.path=/usr/share/java,/usr/share/java/kafka-connect-jdbc

I have my connector jars here-

/usr/share/java/kafka-connect-jdbc

-rw-r--r-- 1 root root  906708 Jul 29 01:18 zookeeper-3.4.13.jar
-rw-r--r-- 1 root root   74798 Jul 29 01:18 zkclient-0.10.jar
-rw-r--r-- 1 root root 5575351 Jul 29 01:18 sqlite-jdbc-3.8.11.2.jar
-rw-r--r-- 1 root root   41203 Jul 29 01:18 slf4j-api-1.7.25.jar
-rw-r--r-- 1 root root  658466 Jul 29 01:18 postgresql-9.4-1206-jdbc41.jar
-rw-r--r-- 1 root root 1292696 Jul 29 01:18 netty-3.10.6.Final.jar
-rw-r--r-- 1 root root  489884 Jul 29 01:18 log4j-1.2.17.jar
-rw-r--r-- 1 root root  211219 Jul 29 01:18 kafka-connect-jdbc-5.0.0.jar
-rw-r--r-- 1 root root  317816 Jul 29 01:18 jtds-1.3.1.jar
-rw-r--r-- 1 root root   87325 Jul 29 01:18 jline-0.9.94.jar
-rw-r--r-- 1 root root   20844 Jul 29 01:18 common-utils-5.0.0.jar
-rw-r--r-- 1 root root   20437 Jul 29 01:18 audience-annotations-0.5.0.jar
-rw-r----- 1 root root 2132635 Nov 11 16:31 mysql-connector-java-8.0.13.jar

I am able to run the standalone mode by running the script in this way-

/usr/bin/connect-standalone /etc/kafka/connect-standalone.properties /etc/kafka-connect-jdbc/source-quickstart-mysql.properties

But when I try to invoke the REST API to run a distributed mode connector , I get the error:

curl -X POST -H "Accept:application/json" -H "Content-Type:application/json" X.X.X.X:8083/connectors/ -d '{"name": "linuxemp-connector", "config": { "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector", "tasks.max": "1", "connection.url": "jdbc:mysql://Y.Y.Y.Y:3306/linux_db?user=groot&password=pwd","table.whitelist": "emp","mode": "timestamp","incrementing.column.name":"empid","topic.prefix": "mysqlconnector-" } }'

error-

{"error_code":400,"message":"Connector configuration is invalid and contains the following 2 error(s):\nInvalid value java.sql.SQLException: No suitable driver found for jdbc:mysql://Y.Y.Y.Y:3306/linux_db?user=groot&password=pwd for configuration Couldn't open connection to jdbc:mysql://Y.Y.Y.Y:3306/linux_db?user=groot&password=pwd\nInvalid value java.sql.SQLException: No suitable driver found for jdbc:mysql://Y.Y.Y.Y:3306/linux_db?user=groot&password=pwd for configuration Couldn't open connection to jdbc:mysql://Y.Y.Y.Y:3306/linux_db?user=groot&password=pwd\nYou can also find the above list of errors at the endpoint `/{connectorType}/config/validate`"}

note- connector jars are placed on all connect nodes , plugin.path is same on all connect nodes and kafka-connect service is up and running .

What am I missing ? Why am I not able to submit REST call to start a distributed connect worker/task for this mysql pipeline ? This works absolutely fine with standalone mode . But throws error with distributed mode .

Please help!

Thanks !


回答1:


By fixing below things, the issue got resolved -

1.Changed permissions of /usr/share/java/kafka-connect-jdbc/mysql-connector-java-8.0.13.jar to 755 2.Keep only /usr/share/java in plugin path.

3.Change my sql table structure to have one primary key and one column property with incremental nature or timestamp.




回答2:


I solved the problem specifing CLASSPATH to the driver like this:

CLASSPATH=/Users/christian/kafka/confluent-5.3.1/share/java/kafka-connect-jdbc/mysql-connector-java-8.0.18.jar connect-standalone.sh worker.properties etc/kafka-connect-jdbc/mysql-jdbc-fp.properties


来源:https://stackoverflow.com/questions/53321726/kafka-connect-jdbc-sqlexception-no-suitable-driver-only-when-using-distribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!