Kafka修炼日志(一):单节点使用问题一二

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介:  根据官方文档修炼Kafka神器,本文简要介绍Kafka特性和优势,以及在实战当中遇到的两个问题及解决方式。

根据官方文档修炼Kafka神器,详细内容请戳这里。本文简要介绍Kafka特性和优势,以及在实战当中遇到的两个问题及解决方式。本文为Kafka系列文章,请关注后续更新。

      Kafka版本:2.12-0.10.2.0

      操作系统:CentOS 6.5

Kafka的三个特性:

   (1)可以发布和订阅Records流,相当于一个消息队列或者消息系统;

   (2)可以存储Records流,并且具有容错性;

   (3)可以对Records流进行处理。

Kafka的两个优势:

   (1)通过建立实时的流数据管道,可靠的在系统间或应用间获取数据;

   (2)通过建立实时的流应用,转换成或者反应成数据流。

问题1:Kafka的Source和Binary:

      在使用官方教程学习当中,进行到Step 2时,运行如下命令,出现找不到main class的错误。

[root@localhost kafka-0.10.2.0-src]# ./bin/zookeeper-server-start.sh config/zookeeper.properties
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain

image.gifimage.gif 百思不得其解,考虑是否因为Linux自带JDK,于是卸载JDK,安装JDK1.8,问题依旧,开始Google求助,在StackOverflow官网找到解决方案,原因是下错了包。使用的是未经过编译的Source,下载Binary后一切恢复正常。

问题2:按照官方教程找不到server.properties进程:

      问题1解决后,一切操作正常,直到运行到如下命令,没有显示相应的进程信息。

[root@localhost kafka_2.12-0.10.2.0]# ps aux | grep server1.properties
root     28779  0.0  0.0 103252   876 pts/2    S+   11:14   0:00 grep server1.properties

      开始抓狂,怀疑是命令问题,于是开始研究ps命令,试了ps -ef依旧无果,使用jps命令发现三个Kafka进程运行正常,但无法和server1.properties对应起来。

[root@localhost kafka_2.12-0.10.2.0]# jps
22596 Kafka
23221 Kafka
25689 Jps
22909 Kafka
22318 QuorumPeerMain

      想到可以利用PID查找对应的进程名,结果如下,三个Kafka进程之间无任何区别,依旧无法将PID和server1.properties对应。

[root@localhost kafka_2.12-0.10.2.0]# ps aux | grep 22596
root     22596  1.4  4.5 7892660 679216 pts/3  Sl   15:12   2:08 /home/jdk1.8.0_121/bin/java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true -Xloggc:/home/kafka_2.12-0.10.2.0/bin/../logs/kafkaServer-gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dkafka.logs.dir=/home/kafka_2.12-0.10.2.0/bin/../logs -Dlog4j.configuration=file:./bin/../config/log4j.properties -cp .:/home/jdk1.8.0_121/lib/dt.jar:/home/jdk1.8.0_121/lib/tools.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/aopalliance-repackaged-2.5.0-b05.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/argparse4j-0.7.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/connect-api-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/connect-file-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/connect-json-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/connect-runtime-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/connect-transforms-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/guava-18.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/hk2-api-2.5.0-b05.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/hk2-locator-2.5.0-b05.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/hk2-utils-2.5.0-b05.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-annotations-2.8.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-annotations-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-core-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-databind-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-jaxrs-base-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-jaxrs-json-provider-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-module-jaxb-annotations-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javassist-3.20.0-GA.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javax.annotation-api-1.2.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javax.inject-1.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javax.inject-2.5.0-b05.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javax.servlet-api-3.1.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javax.ws.rs-api-2.0.1.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-client-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-common-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-container-servlet-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-container-servlet-core-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-guava-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-media-jaxb-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-server-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-continuation-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-http-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-io-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-security-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-server-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-servlet-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-servlets-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-util-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jopt-simple-5.0.3.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka_2.12-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka_2.12-0.10.2.0-sources.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka_2.12-0.10.2.0-test-sources.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka-clients-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka-log4j-appender-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka-streams-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka-streams-examples-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka-tools-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/log4j-1.2.17.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/lz4-1.3.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/metrics-core-2.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/osgi-resource-locator-1.0.1.jar:/home/kafka_2.12-0.10.2.0/b
root     25632  0.0  0.0 103252   832 pts/2    R+   17:42   0:00 grep 22596
[root@localhost kafka_2.12-0.10.2.0]# ps aux | grep 22909
root     22909  0.9  5.5 6837340 821064 pts/3  Sl   Feb28  11:48 /home/jdk1.8.0_121/bin/java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true -Xloggc:/home/kafka_2.12-0.10.2.0/bin/../logs/kafkaServer-gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dkafka.logs.dir=/home/kafka_2.12-0.10.2.0/bin/../logs -Dlog4j.configuration=file:./bin/../config/log4j.properties -cp .:/home/jdk1.8.0_121/lib/dt.jar:/home/jdk1.8.0_121/lib/tools.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/aopalliance-repackaged-2.5.0-b05.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/argparse4j-0.7.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/connect-api-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/connect-file-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/connect-json-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/connect-runtime-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/connect-transforms-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/guava-18.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/hk2-api-2.5.0-b05.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/hk2-locator-2.5.0-b05.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/hk2-utils-2.5.0-b05.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-annotations-2.8.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-annotations-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-core-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-databind-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-jaxrs-base-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-jaxrs-json-provider-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jackson-module-jaxb-annotations-2.8.5.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javassist-3.20.0-GA.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javax.annotation-api-1.2.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javax.inject-1.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javax.inject-2.5.0-b05.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javax.servlet-api-3.1.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/javax.ws.rs-api-2.0.1.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-client-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-common-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-container-servlet-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-container-servlet-core-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-guava-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-media-jaxb-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jersey-server-2.24.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-continuation-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-http-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-io-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-security-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-server-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-servlet-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-servlets-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jetty-util-9.2.15.v20160210.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/jopt-simple-5.0.3.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka_2.12-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka_2.12-0.10.2.0-sources.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka_2.12-0.10.2.0-test-sources.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka-clients-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka-log4j-appender-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka-streams-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka-streams-examples-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/kafka-tools-0.10.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/log4j-1.2.17.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/lz4-1.3.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/metrics-core-2.2.0.jar:/home/kafka_2.12-0.10.2.0/bin/../libs/osgi-resource-locator-1.0.1.jar:/home/kafka_2.12-0.10.2.0/b
root     28818  0.0  0.0 103252   840 pts/2    R+   11:22   0:00 grep 22909

     思考之后,决定使用lsof命令,查询端口号和PID之间的对应关系,因为按照教程部署的Kafka三个节点都在本机上,以端口号区分,server1.properties的端口号设置的是9093。

[root@localhost kafka_2.12-0.10.2.0]# lsof -i:9093
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    22909 root  102u  IPv6 278744      0t0  TCP *:9093 (LISTEN)
java    22909 root  103u  IPv6 292045      0t0  TCP localhost:9093->localhost:49648 (ESTABLISHED)
java    25991 root   84u  IPv6 292044      0t0  TCP localhost:49648->localhost:9093 (ESTABLISHED)

     问题解决,可以继续教程进行fault-tolerance测试了。

   

本文属作者原创,转贴请声明!

相关文章
|
1月前
|
存储 消息中间件 大数据
大数据-69 Kafka 高级特性 物理存储 实机查看分析 日志存储一篇详解
大数据-69 Kafka 高级特性 物理存储 实机查看分析 日志存储一篇详解
32 4
|
1月前
|
存储 消息中间件 大数据
大数据-70 Kafka 高级特性 物理存储 日志存储 日志清理: 日志删除与日志压缩
大数据-70 Kafka 高级特性 物理存储 日志存储 日志清理: 日志删除与日志压缩
38 1
|
1月前
|
存储 消息中间件 大数据
大数据-68 Kafka 高级特性 物理存储 日志存储概述
大数据-68 Kafka 高级特性 物理存储 日志存储概述
26 1
|
2月前
|
消息中间件 Kafka API
python之kafka日志
python之kafka日志
25 3
|
2月前
|
消息中间件 存储 监控
Kafka的logs目录下的文件都是什么日志?
Kafka的logs目录下的文件都是什么日志?
107 11
|
3月前
|
消息中间件 监控 Kafka
Filebeat+Kafka+Logstash+Elasticsearch+Kibana 构建日志分析系统
【8月更文挑战第13天】Filebeat+Kafka+Logstash+Elasticsearch+Kibana 构建日志分析系统
192 3
|
3月前
|
消息中间件 Java Kafka
【Azure 事件中心】开启 Apache Flink 制造者 Producer 示例代码中的日志输出 (连接 Azure Event Hub Kafka 终结点)
【Azure 事件中心】开启 Apache Flink 制造者 Producer 示例代码中的日志输出 (连接 Azure Event Hub Kafka 终结点)
|
5天前
|
XML 安全 Java
【日志框架整合】Slf4j、Log4j、Log4j2、Logback配置模板
本文介绍了Java日志框架的基本概念和使用方法,重点讨论了SLF4J、Log4j、Logback和Log4j2之间的关系及其性能对比。SLF4J作为一个日志抽象层,允许开发者使用统一的日志接口,而Log4j、Logback和Log4j2则是具体的日志实现框架。Log4j2在性能上优于Logback,推荐在新项目中使用。文章还详细说明了如何在Spring Boot项目中配置Log4j2和Logback,以及如何使用Lombok简化日志记录。最后,提供了一些日志配置的最佳实践,包括滚动日志、统一日志格式和提高日志性能的方法。
91 30
【日志框架整合】Slf4j、Log4j、Log4j2、Logback配置模板
|
1月前
|
XML JSON Java
Logback 与 log4j2 性能对比:谁才是日志框架的性能王者?
【10月更文挑战第5天】在Java开发中,日志框架是不可或缺的工具,它们帮助我们记录系统运行时的信息、警告和错误,对于开发人员来说至关重要。在众多日志框架中,Logback和log4j2以其卓越的性能和丰富的功能脱颖而出,成为开发者们的首选。本文将深入探讨Logback与log4j2在性能方面的对比,通过详细的分析和实例,帮助大家理解两者之间的性能差异,以便在实际项目中做出更明智的选择。
193 3
|
1月前
|
存储 缓存 关系型数据库
MySQL事务日志-Redo Log工作原理分析
事务的隔离性和原子性分别通过锁和事务日志实现,而持久性则依赖于事务日志中的`Redo Log`。在MySQL中,`Redo Log`确保已提交事务的数据能持久保存,即使系统崩溃也能通过重做日志恢复数据。其工作原理是记录数据在内存中的更改,待事务提交时写入磁盘。此外,`Redo Log`采用简单的物理日志格式和高效的顺序IO,确保快速提交。通过不同的落盘策略,可在性能和安全性之间做出权衡。
1611 14
下一篇
无影云桌面