zoukankan      html  css  js  c++  java
  • Apache Kafka学习 (二)

    1. 配置server.properties

    > cp config/server.properties config/server-1.properties
    > cp config/server.properties config/server-2.properties

    2. 编辑server.properties

    config/server-1.properties:

    ------------------------------------------------

    broker.id=1
    listeners=PLAINTEXT://:9093
    log.dir=/tmp/kafka-logs-1

    ------------------------------------------------

    config/server-2.properties:

    ------------------------------------------------

    broker.id=2
    listeners=PLAINTEXT://:9094
    log.dir=/tmp/kafka-logs-2

    ------------------------------------------------

    3. 我们如果已经启动了zookeeper和一个9092的单节点,那么只要再启动那两个新节点就好了

    (We already have Zookeeper and our single node started, so we just need to start the two new nodes)

    > bin/kafka-server-start.sh config/server-1.properties &
    ...
    > bin/kafka-server-start.sh config/server-2.properties &
    ...

    4. 新建一个有3个复制的主题

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

    5. 查看主题

    > bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic

    6. 发布主题的消息

    > bin/kafka-console-producer.sh --broker-list localhost:9092 --topic my-replicated-topic

    7. 测试容错机制

    > ps aux | grep server-1.properties

    7564 ttys002 0:15.91 /System/Library/Frameworks/JavaVM.framework/Versions/1.8/Home/bin/java...
    > kill -9 7564

    8. 消费主题的消息

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

  • 相关阅读:
    HDU 5818 Joint Stacks
    HDU 5816 Hearthstone
    HDU 5812 Distance
    HDU 5807 Keep In Touch
    HDU 5798 Stabilization
    HDU 5543 Pick The Sticks
    Light OJ 1393 Crazy Calendar (尼姆博弈)
    NEFU 2016省赛演练一 I题 (模拟题)
    NEFU 2016省赛演练一 F题 (高精度加法)
    NEFU 2016省赛演练一 B题(递推)
  • 原文地址:https://www.cnblogs.com/davidgu/p/6598145.html
Copyright © 2011-2022 走看看