Precondition
jdk安裝
zookeeper安裝
安裝kafka
kafka 官網(wǎng):
http://kafka.apache.org/downloads.html
zookeeper官網(wǎng):
http://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.8/
tar zxvf kafka_2.11-0.8.2.2.tgz
mv kafka_2.11-0.8.2.2 kafka
cd kafka
ps: 最好建立軟鏈 ln -s source newFolder
啟動Kafka 服務(wù)
使用kafka-server-start.sh 啟動kafka 服務(wù):
bin/kafka-server-start.sh config/server.properties
[2015-10-26 04:28:56,115] INFO Verifying properties (kafka.utils.VerifiableProperties)
[2015-10-26 04:28:56,141] INFO Property broker.id is overridden to 0 (kafka.utils.VerifiableProperties)
創(chuàng)建topic
使用kafka-topics.sh 創(chuàng)建單分區(qū)單副本的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 test
產(chǎn)生消息
使用kafka-console-producer.sh 發(fā)送消息:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
Hello world携狭!
Hello Kafka叁温!
消費(fèi)消息
使用kafka-console-consumer.sh 接收消息并在終端打釉【隆:
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
Hello world!
Hello Kafka!
引用:
https://mos.meituan.com/library/32/how-to-install-kafka-on-centos7/