一、下載kafka_2.12-2.3.0 並解壓文件
1. 下載地址
http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.3.0/kafka_2.12-2.3.0.tgz
2. 解壓文件
tar -zxvf kafka_2.12-2.3.0.tgz
二、配置啓動參數
1. cd
cd config 修改 server.properties
2. 末尾添加
advertised.host.name=192.168.1.119 #本機IP
advertised.listeners=PLAINTEXT://106.14.202.33:9092 #外部連接使用IP:端口
三、啓動命令(啓動kafka需要先啓動zookeeper)
1. 控制檯打印輸出
bin/kafka-server-start.sh config/server.properties
或者
bin/kafka-server-start.sh -daemon config/server.properties
2. 後臺服務運行
sh bin/kafka-server-start.sh config/server.properties &
四、創建主題用於消費使用
1. 創建主題消費
bin/kafka-topics.sh --create --zookeeper 127.0.0.1:2181 --replication-factor 1 --partitions 1 --topic maxwell
2. 刪除主題
bin/kafka-topics.sh --delete --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic maxwell
五、接收對應主題推送的數據信息
1. 接收對應主題消息
bin/kafka-console-consumer.sh --bootstrap-server 172.19.22.27:9092 --topic maxwell --from-beginning
六、列出當前已創建的所有主題
bin/kafka-topics.sh --list --zookeeper localhost:2181