我在新的 linux centos 7 上安装了 kafka confluent oss 4.0,但 kafka connect 无法启动。

重现步骤 :

 - Install Oracle JDK 8
 - Copy confluent-4.0.0 folder on opt/confluent-4.0.0
 - Run /opt/confluent-4.0.0/confluent start

结果 :
Starting zookeeper
zookeeper is [UP]
Starting kafka
kafka is [UP]
Starting schema-registry
schema-registry is [UP]
Starting kafka-rest
kafka-rest is [UP]
Starting connect
\Kafka Connect failed to start
connect is [DOWN]

错误日志(connect.stderr):
Exception in thread "main" java.lang.NoClassDefFoundError: io/confluent/connect/storage/StorageSinkConnectorConfig
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
        at org.apache.kafka.connect.runtime.isolation.PluginClassLoader.loadClass(PluginClassLoader.java:54)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
        at java.lang.Class.getConstructor0(Class.java:3075)
        at java.lang.Class.newInstance(Class.java:412)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.getPluginDesc(DelegatingClassLoader.java:279)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scanPluginPath(DelegatingClassLoader.java:260)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scanUrlsAndAddPlugins(DelegatingClassLoader.java:201)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.registerPlugin(DelegatingClassLoader.java:193)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.initLoaders(DelegatingClassLoader.java:153)
        at org.apache.kafka.connect.runtime.isolation.Plugins.<init>(Plugins.java:47)
        at org.apache.kafka.connect.cli.ConnectDistributed.main(ConnectDistributed.java:70)
Caused by: java.lang.ClassNotFoundException: io.confluent.connect.storage.StorageSinkConnectorConfig
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at org.apache.kafka.connect.runtime.isolation.PluginClassLoader.loadClass(PluginClassLoader.java:62)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 22 more

附加信息:

java 版:
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode

Centos 版本:
centos-release-7-4.1708.el7.centos.x86_64

[编辑:30/11/2017]
在每个属性文件中编辑 plugin.path 变量并没有解决问题。

包含“plugin.path”变量的文件列表:
./etc/schema-registry/connect-avro-distributed.properties:84:plugin.path=/opt/confluent-4.0.0/share/java
./etc/schema-registry/connect-avro-standalone.properties:51:plugin.path=/opt/confluent-4.0.0/share/java
./etc/kafka/connect-distributed.properties:95:plugin.path=/opt/confluent-4.0.0/share/java
./etc/kafka/connect-standalone.properties:50:plugin.path=/opt/confluent-4.0.0/share/java

最佳答案

在 Confluent 4.0.0 中,默认情况下为 Kafka Connect 启用了使用 plugin.path 的类加载隔离。

当你从 debrpm 包安装 Confluent Platform 时,你的 plugin.path 的默认位置是事先知道的。

但是,当您在文件系统中的某处下载并提取 Confluent Platform 的 ziptar.gz 存档时,它被设置为:
plugin.path=share/java
这是一个相对路径,因为当您将 Confluent Platform 作为存档下载( ziptar.gz )时,您提取存档的位置是未知的(在上面的示例中,它是 /opt/confluent-4.0.0/ )。

如果您从解压缩 Confluent 平台的目录运行它,CLI 或 Connect 的 bin 脚本将能够猜测此位置:

例如,在上面的例子中:
cd /opt/confluent-4.0.0./bin/confluent start
为了让您能够从文件系统中的任何目录启动 Connect,假设 Confluent Platform 的 bin 目录在您的 PATH 中,您需要将属性 plugin.path 设置为插件的绝对路径位置:

要使用 Confluent CLI 编辑:
etc/schema-registry/connect-avro-distributed.properties
并适当设置您的 plugin.path (此处: plugin.path=/opt/confluent-4.0.0/share/java )

对于常规 bin 脚本编辑:
./etc/kafka/connect-distributed.properties

./etc/kafka/connect-standalone.properties
并设置您的 plugin.path 如上所述(同样,在您的示例中: plugin.path=/opt/confluent-4.0.0/share/java )。

关于apache-kafka - Kafka Connect 启动失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47555927/

10-10 06:38