kafka完全分布式搭建(2.12版)


1、下載解壓

  tar -xvf kafka_2.12-1.0.0.tgz

2、進入config目錄下,修改server.propeties文件

  broker.id=0 #當前server編號

  port=9092 #使用的端口

  log.dirs=/tmp/kafka-logs-1 #日志存儲目錄

  zookeeper.connect=localhost:2181

3、啟動zookeeper

  zkServer.sh start

4、啟動kafka

  bin/kafka-server-start.sh config/server.properties

**************************************************

使用kafka

1)、創建topic:

  bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

2)、查看topic: 

  bin/kafka-topics.sh --list --zookeeper localhost:2181

3)、生產者

  bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test

4)、消費者

  bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning

5)、刪除topic

  ./bin/kafka-topics --delete --zookeeper 【zookeeper server:port】 --topic 【topic name】

  [server.properties需要 設置delete.topic.enable=true]

**************************************************


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM