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 高级特性 物理存储 实机查看分析 日志存储一篇详解
36 4
|
1月前
|
存储 消息中间件 大数据
大数据-70 Kafka 高级特性 物理存储 日志存储 日志清理: 日志删除与日志压缩
大数据-70 Kafka 高级特性 物理存储 日志存储 日志清理: 日志删除与日志压缩
41 1
|
1月前
|
存储 消息中间件 大数据
大数据-68 Kafka 高级特性 物理存储 日志存储概述
大数据-68 Kafka 高级特性 物理存储 日志存储概述
26 1
|
2月前
|
消息中间件 Kafka API
python之kafka日志
python之kafka日志
32 3
|
2月前
|
消息中间件 存储 监控
Kafka的logs目录下的文件都是什么日志?
Kafka的logs目录下的文件都是什么日志?
135 11
|
3月前
|
消息中间件 监控 Kafka
Filebeat+Kafka+Logstash+Elasticsearch+Kibana 构建日志分析系统
【8月更文挑战第13天】Filebeat+Kafka+Logstash+Elasticsearch+Kibana 构建日志分析系统
206 3
|
3月前
|
消息中间件 Java Kafka
【Azure 事件中心】开启 Apache Flink 制造者 Producer 示例代码中的日志输出 (连接 Azure Event Hub Kafka 终结点)
【Azure 事件中心】开启 Apache Flink 制造者 Producer 示例代码中的日志输出 (连接 Azure Event Hub Kafka 终结点)
|
1月前
|
消息中间件 存储 运维
为什么说Kafka还不是完美的实时数据通道
【10月更文挑战第19天】Kafka 虽然作为数据通道被广泛应用,但在实时性、数据一致性、性能及管理方面存在局限。数据延迟受消息堆积和分区再平衡影响;数据一致性难以达到恰好一次;性能瓶颈在于网络和磁盘I/O;管理复杂性涉及集群配置与版本升级。
|
1月前
|
消息中间件 Java Kafka
Flink-04 Flink Java 3分钟上手 FlinkKafkaConsumer消费Kafka数据 进行计算SingleOutputStreamOperatorDataStreamSource
Flink-04 Flink Java 3分钟上手 FlinkKafkaConsumer消费Kafka数据 进行计算SingleOutputStreamOperatorDataStreamSource
47 1
|
3月前
|
消息中间件 Java Kafka
Kafka不重复消费的终极秘籍!解锁幂等性、偏移量、去重神器,让你的数据流稳如老狗,告别数据混乱时代!
【8月更文挑战第24天】Apache Kafka作为一款领先的分布式流处理平台,凭借其卓越的高吞吐量与低延迟特性,在大数据处理领域中占据重要地位。然而,在利用Kafka进行数据处理时,如何有效避免重复消费成为众多开发者关注的焦点。本文深入探讨了Kafka中可能出现重复消费的原因,并提出了四种实用的解决方案:利用消息偏移量手动控制消费进度;启用幂等性生产者确保消息不被重复发送;在消费者端实施去重机制;以及借助Kafka的事务支持实现精确的一次性处理。通过这些方法,开发者可根据不同的应用场景灵活选择最适合的策略,从而保障数据处理的准确性和一致性。
280 9
下一篇
无影云桌面