Kafka入门
下载
官网地址:https://kafka.apache.org/
修改配置文件
-
修改config目录下:zookeeper.properties
- -
修改config目录下:server.properties
启动zookeeper
d:\Program\kafka_2.13-3.2.0> bin\windows\zookeeper-server-start.bat config\zookeeper.properties
启动Kafka
d:\Program\kafka_2.13-3.2.0> bin\windows\kafka-server-start.bat config\server.properties
创建主题
d:\Program\kafka_2.13-3.2.0\bin\windows> kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
创建主题:1个主题,一个分区,主题名 test
查看主题
d:\Program\kafka_2.13-3.2.0\bin\windows> kafka-topics.bat --list --bootstrap-server localhost:9092
test
查看本机的所有主题
发送消息
以生产者身份发送消息
d:\Program\kafka_2.13-3.2.0\bin\windows>kafka-console-producer.bat --broker-list localhost:9092 --topic test
>
往本机的 test主题上发消息
接收消息
d:\Program\kafka_2.13-3.2.0\bin\windows> kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
接收指定主机的 消息