文檔參考:http://kafka.apache.org/documentation.html
下載代碼:
tar
-xzf kafka_2.11-0.11.0.0.tgz
cd
kafka_2.11-0.11.0.0
啟動
bin
/zookeeper-server-start
.sh config
/zookeeper
.properties
創建topic(主題為test,只有一個分區,一個副本)
bin
/kafka-topics
.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic
test
查看topic
bin
/kafka-topics
.sh --list --zookeeper localhost:2181
發送消息
bin
/kafka-console-producer
.sh --broker-list localhost:9092 --topic
test
啟動消費者
bin
/kafka-console-consumer
.sh --bootstrap-server localhost:9092 --topic
test
--from-beginning
?
設置多集群:
config
/server
.properties config
/server-1
.properties
config
/server
.properties config
/server-2
.properties
配置文件
config/server-1.properties:
????
broker.id=1
????
listeners=PLAINTEXT://:9093
????
log.dir=/tmp/kafka-logs-1
config/server-2.properties:
????
broker.id=2
????
listeners=PLAINTEXT://:9094
????
log.dir=/tmp/kafka-logs-2
broker.id
屬性是集群中的每個節點的唯一和永久的名字?