连接器任务状态无法连接

r8xiu3jd  于 2021-06-06  发布在  Kafka
关注(0)|答案(1)|浏览(579)

连接器的任务状态失败,错误为:

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
x6yk4ghg

x6yk4ghg1#

它找不到内置的Kafka类,也找不到连接器
noclassdeffounderror:org/apache/kafka/clients/admin/adminclient
...
我正在使用Kafka(0.10.0.2.5)
确保您正在运行1)与kafka broker匹配的连接服务器版本2)使用的连接器使用的代码用于该版本的连接
例如,adminclient只存在于kafka 0.11+中。
在最近的hdp版本中,您得到了kafka1.1(不同于0.11),这是最新debezium的构建和测试版本https://debezium.io/docs/releases/
debezium需要adminclient来生成和注册主题信息,所以我不确定它是否能在0.10这样的旧版本上工作
它在kafkawiki中声明,较新版本的connectserver可以与旧的代理通信,但是连接器类所使用的协议有待商榷。

相关问题