zoukankan      html  css  js  c++  java
  • kafka配置

    官网:http://kafka.apache.org/

    主要有3种安装方式:

    1. 单机单broker

    2. 单机多broker

    3. 多机多broker

    1. wget http://mirror.bit.edu.cn/apache/kafka/0.10.0.1/kafka_2.11-0.10.0.1.tgz

    2. (可选,因为kafka自带zookeeper)wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz

    配置ZOOKEEPER_HOME,然后bin下./zkServer.sh start即可启动zookeeper。

    (多机zookeeper需额外新增conf下zoo.cfg)

    3. 启动kafka

    (可选)配置KAFKA_HOME,然后就可以用全局下启动命令

    3.1 单机单broker

    3.1.1 启动:kafka-server-start.sh config/server.properties

    3.1.2 新建topic:kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic kafka_topic_1

    其中--replication-factor表示备份数量

    --partitions表示分区数量

    3.1.3 新建consumer:kafka-console-consumer.sh --zookeeper localhost:2181 --topic kafka_topic_1 --from-beginning

    3.1.4 新建producer:kafka-console-producer.sh --broker-list localhost:9092 --topic kafka_topic_1

    其中--broker-list表示了消息要推送的地址<ip:port>

    然后开始console中输入message,在consumer console中就会有消息显示。

    3.2 单机多broker

    3.2.1 启动server1:

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

    启动server2:

      cp server.properties server2.properties

      修改其中的broker.id=2, listeners=PLAINTEXT://:9093, log.dirs=/tmp/kafka-logs2

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

    启动server3:

      cp server.properties server3.properties

      修改其中的broker.id=3, listeners=PLAINTEXT://:9094, log.dirs=/tmp/kafka-logs3

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

     

    3.2.2 新建topic:kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 3 --topic kafka_topic_2

    单机3个备份,3个分区

    3.2.3 新建consumer:kafka-console-consumer.sh --zookeeper localhost:2181 --topic kafka_topic_2 --from-beginning

    3.2.4 新建producer:kafka-console-producer.sh --broker-list localhost:9092 --topic kafka_topic_2

     //blabla自己测试消息发送

    3.2.5 查看各个server状态

      kafka-topics.sh --describe --zookeeper localhost:2181 --topic kafka_topic_2 

    3.3 多机多broker

    略 2333333333 

  • 相关阅读:
    23种设计模式之责任链模式
    23种设计模式之中介者模式
    23种设计模式之代理模式
    23种设计模式之原型模式
    23种设计模式之模板方法模式
    23种设计模式之建造者模式
    23中设计模式之抽象工厂模式
    批处理产生001到999之间的数字
    批处理随机显示星期几
    批处理简易密码登录
  • 原文地址:https://www.cnblogs.com/xxx0624/p/5818986.html
Copyright © 2011-2022 走看看