學習kafka筆記

一:概念bootstrap

二:部署server

   使用kafka自帶的zookeeper集羣啓動部署

(1)下載好kafka的包,並解壓到/opt/kafka/目錄下kafka

     tar zxvf kafka_2.11-2.2.1.tgz -C /opt/kafkait

(2)啓動自帶的zookeeper(2181端口)io

    cd /opt/kafka/kafka_2.11-2.2.1/console

    bin/zookeeper-server-start.sh config/zookeeper.properties  test

  (3)啓動kafka(9092端口)集羣

    bin/kafka-server-start.sh -daemon  config/server.propertieszookeeper

    lsof -i :9092   (列出9092端口是否在使用)

 (4)建立topic

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

   其中:--partitions 3 //建立1個分區

              --replications-factor 1 //複製一份

              --topic //主題爲test1

    bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic test1  (查看topic的描述命令)

  (5)建立生產者

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

    (6)  建立消費者

     bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test1 --from-beginning

      注:舊版本是  bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test1

相關文章
相關標籤/搜索