今天在使用kafka的时候,进行以下指令测试时报了个错误:

./lib/kafka/bin/connect-distributed.sh ./etc/kafka/conf.dist/connect-distributed-Oracle.properties ./etc/kafka/conf.dist/OracleSourceConnector.properties


[root@cluster2-4 KAFKA-4.1.0-1.4.1.0.p0.4]# ./lib/kafka/bin/connect-distributed.sh ./etc/kafka/conf.dist/connect-distributed-Oracle.properties ./etc/kafka/conf.dist/OracleSourceConnector.properties
log4j:ERROR Could not read configuration file from URL [file:./lib/kafka/bin/../config/connect-log4j.properties].
java.io.FileNotFoundException: ./lib/kafka/bin/../config/connect-log4j.properties (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:557)
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
    at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:66)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
    at org.apache.kafka.connect.cli.ConnectDistributed.<clinit>(ConnectDistributed.java:55)
log4j:ERROR Ignoring configuration file [file:./lib/kafka/bin/../config/connect-log4j.properties].
log4j:WARN No appenders could be found for logger (org.apache.kafka.connect.runtime.WorkerInfo).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

 

可以很明显的看出错误提示是找不到connect-log4j.properties这个配置文件。网上有些人说把这个文件弄到config中就好了,但是我看了我这个config文件中,其实有这个文件:

解决办法:

将配置文件的路径指向这个路径,执行如下命令:

export KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:/opt/cloudera/parcels/KAFKA/etc/kafka/conf.dist/connect-log4j.properties

我这个是CDH中安装的kafka,所以路径可能会不太一样。这样指定以后就可以了,在执行也不会报错了:

Logo

Kafka开源项目指南提供详尽教程,助开发者掌握其架构、配置和使用,实现高效数据流管理和实时处理。它高性能、可扩展,适合日志收集和实时数据处理,通过持久化保障数据安全,是企业大数据生态系统的核心。

更多推荐