kafka須要配合zookeeper使用,在安裝kafka以前,須要先安裝zookeeper集羣,關於安裝zookeeper集羣,能夠參考:http://www.javashuo.com/article/p-pfauykmu-do.htmlhtml
ip地址 | 安裝服務 |
---|---|
192.168.1.11 | zookeeper-3.4.十、kafka2.十、kafka-manager |
192.168.1.12 | zookeeper-3.4.十、kafka2.10 |
192.168.1.13 | zookeeper-3.4.十、kafka2.10 |
關於JDK安裝 ,能夠參考: http://www.javashuo.com/article/p-rtvzuadn-eq.htmlapache
下載地址: https://www.apache.org/dyn/closer.cgi?path=/kafka/2.1.1/kafka_2.11-2.1.1.tgzbootstrap
cd /usr/local/src tar zxvf kafka_2.11-2.1.1.tgz mv kafka_2.11-2.1.1 /usr/local/kafka
vim /usr/local/kafka/config/server.properties
具體參數以下:vim
broker.id=1bash
port=9092服務器
host.name=192.168.1.11fetch
delete.topic.enable=truespa
log.retention.hours=168
message.max.byte=5242880
default.replication.factor=2
replica.fetch.max.bytes=5242880設計
zookeeper.connect= 192.168.1.11:2181,192.168.1.12:2181,192.168.1.13:2181code
cd /usr/local/kafka/kafka_2.11-2.1.1/bin ./kafka-server-start.sh -daemon ../config/server.properties &
./kafka-topics.sh --create --zookeeper 192.168.1.11:2181,192.168.1.12:2181,192.168.1.13:2181 --replication-factor 2 --partitions 1 --topic tttt
參數解釋:
複製兩份
--replication-factor 2
建立1個分區
--partitions 1
topic 名稱
--topic tttt
./kafka-topics.sh --list --zookeeper 192.168.1.11:2181,192.168.1.12:2181,192.168.1.13:2181
刪除topic,須要在server.properties中設置delete.topic.enable=true不然只是標記刪除或者直接重啓。
./bin/kafka-topics.sh --delete --zookeeper 192.168.1.11:2181,192.168.1.12:2181,192.168.1.13:2181 --topic tttt
bin/kafka-topics.sh --describe --zookeeper
bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --lis
bin/kafka-consumer-groups.sh --new-consumer --bootstrap-server localhost:9092 --list
bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper localhost:2181 --group test
bin/kafka-consumer-groups.sh --new-consumer --bootstrap-server localhost:9092 --describe --group test-consumer-group