kafka的入门使用
安装
下载路径 (下载.tgz包):https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/
解压安装包,并进到config目录下找到server.properties文件:
编辑
log.dirs=D:\\kafka\\log (注意此处是双\\)
之后进入到kafka的目录下执行下面的命令(需要事先启动zookeeper):
.\bin\windows\kafka-server-start.bat .\config\server.properties
测试
1.创建一个topic
.\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
2.开启生产者
.\bin\windows.\kafka-console-producer.bat --broker-list localhost:9092 --topic test
3.开启消费者
.\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test
在生产者窗口输入的内容会在消费者窗口复现:
end.