一 . kafka 快速安裝使用
1.1 下載kafka
tar -xzf kafka_2.11-0.10.2.0.tgz
cd kafka_2.11-0.10.2.0
1.2 開啟服務 啟動ZooKeeper(如果沒有可以啟用默認的) 和Kafka
注意:下面啟動是非后臺啟動,如果已啟動ZooKeeper不需要第一步
bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties
后臺啟動
nohup bin/kafka-server-start.sh config/server.properties &
或者
bin/kafka-server-start.sh -daemon config/server.properties
1.3 創建一個topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
查看topic
bin/kafka-topics.sh --list --zookeeper localhost:2181
1.4 創建發送信息控制臺(生產者),發送信息(producer)
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
可以在控制臺來發送信息
1.5 開啟一個消費者(consumer)
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning