1、下载kafka安装包
http://kafka.apache.org/downloads
2、解压
tar -zxvf kafka_2.12-2.5.0.tgz -C /home/share/kafka
cd /home/share/kafka/kafka_2.12-2.5.0
3、开启kafka服务
启动zookeeper bin/zookeeper-server-start.sh config/zookeeper.properties 启动Kafka服务端 bin/kafka-server-start.sh config/server.properties
4、创建topic
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
查看创建的主题
bin/kafka-topics.sh --list --zookeeper localhost:2181
5、发送消息
producer生产数据 bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test > consumer来接收数据 bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning