1.下载安装包
wget https://downloads.apache.org/kafka/2.7.0/kafka_2.12-2.7.0.tgz
2.解压安装包
tar -zxvf ./kafka_2.12-2.7.0.tgz -C
mkdir kafka
mv kafka_2.12-2.7.0 kafka
3.开启kafka
./bin/kafka-server-start.sh -daemon ./config/server.properties
4.关闭kafka
./bin/kafka-server-stop.sh ./config/server.properties
5.测试
(1).创建topic
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
(2) 发送消息
./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
(3)接收消息
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
(4)查看topic&删除topic
1.查看
./bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic test
2.删除
./bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic test