0.安裝java環境
可以參考另一篇文章:https://www.cnblogs.com/codedoge/p/10101580.html
1.下載kafka(我下載的是2.11-2.1.0版本)
wget https://mirrors.cnnic.cn/apache/kafka/2.1.0/kafka_2.11-2.1.0.tgz
2.解壓
tar -xzvf kafka_2.11-2.1.0.tgz
3.進入kafka的conf目錄,修改相關配置文件
修改server.properties
4.啟動zookeeper
./bin/zookeeper-server-start.sh ./config/zookeeper.properties
5.新開一個控制台,啟動kafka
./bin/kafka-server-start.sh ./config/server.properties
6.新開一個控制台,創建topic
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
7.查看topic列表
./bin/kafka-topics.sh --list --zookeeper localhost:2181
8.創建生產者
./bin/kafka-console-producer.sh --broker-list 10.1.3.xxx:9092 --topic test
9.新建窗口,創建消費者
#0.9版本之前: ./bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning #0.9版本之后: ./bin/kafka-console-consumer.sh --bootstrap-server 10.1.3.xxx:9092 --topic test --from-beginning