1.Kafka安装
1.1 下载压缩包
wget https://downloads.apache.org/kafka/3.2.1/kafka_2.12-3.2.1.tgz
1.2 解压
tar -zxvf kafka_2.12-3.2.1.tgz
1.3 启动zookeeper
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
1.4 启动Kafka
bin/kafka-server-start.sh -daemon config/server.properties
2.主题
2.1 创建主题
bin/kafka-topics.sh --create --topic product --bootstrap-server localhost:9092
bin/kafka-topics.sh --create --topic create-order --bootstrap-server 127.0.0.1:9092 --partitions 3 --replication-factor 3
创建主题的同时指定分区数以及副本数
2.2 查看主题详细信息
bin/kafka-topics.sh --describe --topic product --bootstrap-server localhost:9092
2.3 查看主题列表信息
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
2.4 删除主题
bin/kafka-topics.sh --delete --topic product --bootstrap-server localhost:9092
3.生产者
3.1 发送消息
bin/kafka-console-producer.sh --topic product --bootstrap-server localhost:9092
4.消费者
4.1 查看消费者组信息
bin/kafka-consumer-groups.sh --group product --bootstrap-server localhost:9092 --describe