下载
kafka下载地址
教程使用版本:
安装
直接解压即可,然后修改配置文件
service.properties
log.dirs=D:\\kit\\kafka_2.13-3.2.1\\kafka-logs
listeners = PLAINTEXT://localhost:9092
zookeeper.properties
dataDir=D:\\kit\\kafka_2.13-3.2.1\\zookeeper
测试验证
启动zookeeper
kafka安装路径下打开cmd
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
启动kafka
kafka安装路径下打开cmd
.\bin\windows\kafka-server-start.bat .\config\server.properties
创建TOPIC
kafka安装路径下打开cmd
.\bin\windows\kafka-topics.bat --create --bootstrap-server localhost:2181 --replication-factor 1 --partitions 1 --topic test-topic
生产者
kafka安装路径下的bin\windows目录下打开cmd
kafka-console-producer.bat --broker-list localhost:9092 --topic test-topic
消费者
kafka安装路径下的bin\windows目录下打开cmd
kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test-topic
关闭Kafka
kafka安装路径下的bin\windows目录下的kafka-server-stop.bat
关闭zookeeper
kafka安装路径下的bin\windows目录下的zookeeper-server-stop.bat
查看topic
.\bin\windows\kafka-topics.bat --list --bootstrap-server localhost:9092
查看topic详情
.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --describe --topic topic名称
修改topic分区
.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --alter --topic topic名称--partitions 数量