scala下载
https://distfiles.macports.org/scala2.12/
查询Kafka版本
sh kafka-topics.sh --version
linux环境启动kafka
1.先启动zk
./bin/zookeeper-server-start.sh -daemon ./config/zookeeper.properties
2.再启动Kafka
./bin/kafka-server-start.sh -daemon ./config/server.properties
3.查询Topic列表
./bin/kafka-topics.sh --bootstrap-server 127.0.0.1:9092 --list --exclude-internal
4.创建topic
./bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 3 --partitions 3 --topic test
5.发送消息
kafka-console-producer.sh --broker-list localhost:9092 --topic <topic>
6.查看kakfa主题消费情况
./bin/kafka-consumer-groups.sh --bootstrap-server <bootstrap_servers> --group <consumer_group_id> --describe
7.查看指定topic
./bin/kafka-topics.sh --bootstrap-server broker_host:port --describe --topic <topic_name>
windows环境
1.启动zookeeper
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
2.启动Kafka
.\bin\windows\kafka-server-start.bat .\config\server.properties
3.查看主题的详情
.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --describe --topic <topic_name>
4.发送消息
kafka-console-producer.bat --broker-list ip:9092 --topic <topic>
5.接受消息
kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning