学习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

相关文章
相关标签/搜索