[Kafka] Kafka Connect JDBC connector : No suitable driver found

    JDBC connector 생성 시 No suitable driver found 에러 발생

    1. 시작하며

    Kafka Connect JDBC Connector 를 사용하여 sink connector를 생성하려고 하였으나 java.sql.SQLException: No suitable driver found 에러가 발생하였다. kafka docker image는 wurstmeister를 사용하였다.

    2. 이슈

    kafka JDBC connector 생성 불가: No suitable driver found

    Caused by: org.apache.kafka.connect.errors.ConnectException: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3307/testdb

    3. 해결

    Connect/J JDBC driver for MySQL를 다운받는다.

    해당 jar 파일을 Confluent의 connect 플러그인이 설치된 디렉토리에 넣는다.

    • 파일명 : mysql-connector-java-8.0.27.jar
    • 경로 : {KAFKA_HOME}/connectors/confluentinc-kafka-connect-jdbc-10.2.5/lib/
    docker cp mysql-connector-java-8.0.27.jar kafka:/opt/kafka_2.13-2.7.1/connectors/confluentinc-kafka-connect-jdbc-10.2.5/lib/

    공식 사이트의 가이드는 다음과 같다.
    https://docs.confluent.io/kafka-connect-jdbc/current/index.html

    MySQL Server
    MySQL provides the Connect/J JDBC driver for MySQL for a number of platforms. Choose the Platform Independent option, and download the Compressed TAR Archive. This file contains both the JAR file and the source code.

    Extract the contents of this tar.gz file to a temporary directory. One of the extracted files will be a jar file (for example, mysql-connector-java-8.0.16.jar), and copy only this JAR file into the share/java/kafka-connect-jdbc directory in your Confluent Platform installation on each of the Connect worker nodes, and then restart all of the Connect worker nodes.

    4. 마치며

    엄청 삽질을 오래 했는데 결론적으로 mysql-connector-java-8.0.27.jar를 confluent의 jdbc connect plugin이 설치된 디렉토리에 넣어주면 정상 동작한다. confluentinc-kafka-connect-jdbc-10.2.5/lib 아래에 넣거나 confluentinc-kafka-connect-jdbc-10.2.5 넣어도 No suitable driver found 가 해결되었다.

    필자는 kafka docker image를 wurstmeister를 사용하였지만 Confluent Docker 를 사용하였다면 아마 경로가 달라질 것 같다. 그러나 kafka-connect-jdbc 가 설치된 경로 이하에 넣어주면 해결될 것이다.

    참고

    반응형

    댓글

    Designed by JB FACTORY