连接器任务状态连接失败

Connector task state fails to connect

连接器的任务状态因错误而失败:

org.apache.kafka.connect.errors.ConnectException: java.lang.NoClassDefFoundError

我是分布式模式下的运行 kafka connect集群,我使用的是ambari部署的kafka(0.10.0.2.5) connect。

我使用 export CLASSPATH=/path to connector/ 给了 debezium mysql 连接器路径。

使用以下命令将连接器配置加载到 Kafka Connect 中:

curl -i -X POST -H "Accept:application/json" \ 
    -H  "Content-Type:application/json" http://localhost:8083/connectors/ \
    -d '{
      "name": "MYSQL_CONNECTOR",
      "config": {
            "connector.class": "io.debezium.connector.mysql.MySqlConnector",
            "database.hostname": "10.224.21.36",
            "database.port": "3306",
            "database.user": "root",
            "database.password": "shobhna",
            "database.server.id": "1",
            "database.server.name": "demo",
            "database.history.kafka.bootstrap.servers": "slnxhadoop04.noid.in:6669",
            "database.history.kafka.topic": "dbhistory.demo" ,
            "include.schema.changes": "true"
       }
    }'

现在检查连接器状态后,出现错误:

 - {"name":"MYSQL_CONNECTOR","connector":{"state":"RUNNING","worker_id":"172.26.177.115:8083"},
   "tasks":[{"state":"FAILED","trace":"org.apache.kafka.connect.errors.ConnectException:
   java.lang.NoClassDefFoundError:
   org/apache/kafka/clients/admin/AdminClient\n\tat
   io.debezium.connector.mysql.MySqlConnectorTask.start(MySqlConnectorTask.java:218)\n\tat
   io.debezium.connector.common.BaseSourceTask.start(BaseSourceTask.java:45)\n\tat
   org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:137)\n\tat
   org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:140)\n\tat
   org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:175)\n\tat
   java.util.concurrent.Executors$RunnableAdapter.cal(Executors.java:511)\n\tat
   java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat
   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat
   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat
   java.lang.Thread.run(Thread.java:745)\nCaused by:
   java.lang.NoClassDefFoundError:
   org/apache/kafka/clients/admin/AdminClient\n\tat
   io.debezium.relational.history.KafkaDatabaseHistory.initializeStorage(KafkaDatabaseHistory.java:336)\n\tat
   io.debezium.connector.mysql.MySqlSchema.intializeHistoryStorage(MySqlSchema.java:260)\n\tat
   io.debezium.connector.mysql.MySqlTaskContext.initializeHistoryStorage(MySqlTaskContext.java:194)\n\tat
   io.debezium.connector.mysql.MySqlConnectorTask.start(MySqlConnectorTask.java:126)\n\t...
   9 more\nCaused by: java.lang.ClassNotFoundException:
   org.apache.kafka.clients.admin.AdminClient  \n\tat
   java.net.URLClassLoader.findClass(URLClassLoader.java:381)\n\tat
   java.lang.ClassLoader.loadClass(ClassLoader.java:424)\n\tat
   sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)\n\tat
   java.lang.ClassLoader.loadClass(ClassLoader.java:357)\n\t

找不到内置的 Kafka class,找不到您的连接器

NoClassDefFoundError: org/apache/kafka/clients/admin/AdminClient

...

i am using kafka(0.10.0.2.5)

确保您是 运行 1) 与您的 Kafka 代理匹配的 Connect Server 版本 2) 使用使用该版本 Connect

代码的连接器

比如AdminClient只存在于Kafka 0.11+。

在最近的 HDP 版本中,您获得了 Kafka 1.1(不同于 0.11),这是最新的 Debezium 构建和测试的版本 https://debezium.io/docs/releases/

Debezium 需要 AdminClient 来创建和注册主题信息,所以我不确定它是否适用于旧版本,例如 0.10

在 Kafka wiki 中声明更新版本的 Connect Server 可以与旧代理通信,但是 Connector classes 使用的协议有待商榷.