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

  • 相关阅读:
    Python—Socket
    python-—计算器
    Python—I-O多路复用
    Python—redis
    《Python数据分析常用手册》一、NumPy和Pandas篇
    python--Selenium-模拟浏览器
    python--selenium简单模拟百度搜索点击器
    关于selenium实现滑块验证
    python 读写、创建 文件的方法(必看)
    Python 爬虫的工具列表大全
  • 原文地址:https://www.cnblogs.com/davidgu/p/6598145.html
Copyright © 2011-2022 走看看