-
下载
https://archive.apache.org/dist/kafka/2.4.1/kafka_2.11-2.4.1.tgz -
解压
-
改配置(kafka_2.11-2.4.0\config\server.properties)
-
启动&测试
在bin/window目录,命令执行bat脚本
# 启动zookeeper:
.\zookeeper-server-start.bat ..\..\config\zookeeper.properties
./zookeeper-server-start.sh -daemon /opt/module/kafka/config/zookeeper.properties # 后台启动
# 启动kafka:
.\kafka-server-start.bat ..\..\config\server.properties
./kafka-server-start.sh -daemon /opt/module/kafka/config/server.properties # 后台启动
# 创建一个topic:
.\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
# 查看已创建topic:
.\kafka-topics.bat --list --zookeeper localhost:2181
./kafka-topics.sh --list --zookeeper localhost:2181
# 创建一个消息消费者:
.\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
# 创建一个消息生产者:
.\kafka-console-producer.bat --broker-list localhost:9092 --topic test
./kafka-console-producer.sh --broker-list localhost:9092 --topic test