zoukankan      html  css  js  c++  java
  • Idea运行Kafka.scala踩坑

    未指定 server.properties

    直接运行时,报错信息如下:

    > Task :core:Kafka.main() FAILED
    USAGE: java [options] KafkaServer server.properties [--override property=value]*
    Option               Description                                         
    ------               -----------                                         
    --override <String>  Optional property that should override values set in
                           server.properties file        
    

    解决方案:Run -> Edit Configurations... ,打开如下图所示对话框,在 Program Arguments 一栏填入 configserver.properties

    未打印运行日志

    Kafka程序确实启动了,但是不知道什么地方出错了?

    > Task :core:Kafka.main()
    log4j:WARN No appenders could be found for logger (kafka.server.KafkaConfig).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
    
    > Task :core:Kafka.main() FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':core:Kafka.main()'.
    > Process 'command 'D:/Common/Java/jdk1.8.0_131/bin/java.exe'' finished with non-zero exit value 1
    

    将 config 目录下的 log4j.properties 文件复制到 core/src/main/resources 目录下,这样可以让 Kafka 在运行时能够输出日志信息:

    Connection refused

    现在运行时能看到日志了:

    [2021-09-07 09:52:16,487] INFO Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
    [2021-09-07 09:52:17,503] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
    java.net.ConnectException: Connection refused: no further information
    	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
    	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
    [2021-09-07 09:52:17,613] INFO Opening socket connection to server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
    [2021-09-07 09:52:18,630] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
    java.net.ConnectException: Connection refused: no further information
    	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
    	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
    

    2181 是 ZooKeeper 的端口,我们知道 Kafka 是需要用到 ZooKeeper 的,所以我们需要先安装和启动 ZooKeeper

    因为我当前的 Kafka 版本是 1.0.0,我们看到它依赖的 zookeeper 是 3.4.10,所以我决定搭建 ZooKeeper 服务时也用 3.4.10 版本:

    个人比较喜欢用Docker来本地测试:Docker安装zookeeper

  • 相关阅读:
    指针如何影响结构体,细节的思考
    【转】oracle null
    【转】JavaScript闭包
    【转】Ext JS xtype
    【转】EXT JS MVC开发模式
    【转】Ext.ajax.request 中的success和failure
    【转】Oracle job procedure 存储过程定时任务
    JDK重要包和Java学习方法论
    rownum
    【转】Js获取当前日期时间及格式化操作
  • 原文地址:https://www.cnblogs.com/kendoziyu/p/15235405.html
Copyright © 2011-2022 走看看