Apache Kafka
Kafka 是一个消息系统,原本开发自 LinkedIn,用作 LinkedIn 的活动流(Activity Stream)和运营数据处理管道(Pipeline)的基础。
下载kafka包
https://www.apache.org/dyn/closer.cgi?path=/kafka/2.2.0/kafka_2.12-2.2.0.tgz
解压后运行:
启动 内建的 zookeeper
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
启动apache kafka
.\bin\windows\kafka-server-start.bat .\config\server.properties
建立一个topic
.\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic javainuse-topic
建立一个生产者(基于某个topic)
.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic javainuse-topic
发送内容
Hello World
建立一个消费者(基于某个topic)使用消息(拿到)
.\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic javainuse-topic --from-beginning
消费内容
参考自
https://www.javainuse.com/misc/apache-kafka-hello-world
kafka-run-class.bat 查看log
.\bin\windows\kafka-run-class.bat kafka.tools.DumpLogSegments --files 00000000000000000000.log --print-data-log > index00.txt
执行后得到如下结果:
Dumping 00000000000000000000.index
offset: 0 position: 0
======================
查看topic
.\bin\windows\kafka-topics.bat --list --zookeeper 127.0.0.1:2181
__consumer_offsets
java_in_use_topic
javainuse-topic
result
查看topic状态
.\bin\windows\kafka-topics.bat --describe --zookeeper localhost:2181 --topic javainuse-topic
Topic:javainuse-topic PartitionCount:1 ReplicationFactor:1 Configs:
Topic: javainuse-topic Partition: 0 Leader: 0 Replicas: 0 Isr: 0
=============
使用Kafka Connect来导入/导出数据(查看各个配置文件,需要输入文件也有导出文件)
echo good>>test.txt
.\bin\windows\connect-standalone.bat config\connect-standalone.properties config\connect-file-source.properties config\connect-file-sink.properties
confluent 当前只支持 linux
Kafka Eagle 可视化监控 只在gthub上 http://download.smartloli.org/