zoukankan      html  css  js  c++  java
  • Kafka系列三之单节点多Broker部署

    写在前面

    很早之前写过单节点单Broker部署,今天有空来简单快速记录一下多Broker的部署方式。其实基本也是差不多的操作。

    单节点单Broker部署及部署:仅有一台机器仅有一个kafka进程
    单节点多Broker部署及部署:仅有一台机器有多个kafka进程 √本文
    那么,当然还有多节点多Broker啦…

    假设建立三个Kafka ,即启动三个进程
    cp server.properties server-1.properties
    cp server.properties server-2.properties
    cp server.properties server-3.properties

    [root@hadoop001 config]# pwd
    /root/app/kafka_2.11-1.1.1/config
    [root@hadoop001 config]# ll server*
    -rw-r--r--. 1 root root 5405 9月  24 18:16 server-1.properties
    -rw-r--r--. 1 root root 5405 9月  24 18:16 server-2.properties
    -rw-r--r--. 1 root root 5405 9月  24 18:16 server-3.properties
    -rw-r--r--. 1 root root 5403 9月  24 18:16 server.properties
    
    

    vim server-1.properties

    # 每个broker 必须不一样才ok
    broker.id=1
    # 每个文件 ,kafka 监听的端口是也得不一致
    listeners=hadoop001:9093
    # 日志存储目录也得不一致,提前建好
    log.dirs=/root/data/kafka-1
    

    http://kafka.apache.org/0100/documentation.html

    单节点多Broker:
    server-1.properties
    server-2.properties
    server-3.properties

    启动

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

    启动之后 jps 就有三个kafka
    jps -m

    创建一个Topic:一个分区三个副本

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

    查看:
    kafka-topics.sh --list --zookeeper hadoop001:2181

    查看指定Topic 的指定信息: kafka-topics.sh --describe --zookeeper hadoop001:2181 --topic test

    一个分区三个副本 ,必然有一个是主的
    Leaders:主的
    Replicas:各个副本存放的位置
    Isr:存活的

    生产消息:
    kafka-console-producer.sh --broker-list hadoop001:9093,hadoop001:9094,hadoop001:9095 --topic test

    消费消息:
    kafka-console.sonsumer.sh --zookeeper hadoop001:2181 --topic test

    只要你的数据能够发送和及接收到,就ok啦

    更多Kafka 相关好文 :https://blog.csdn.net/liuge36/article/category/9392861

  • 相关阅读:
    安装oracle 使用vnc无法打开terminal,解决办法
    linux服务器配置本地yum仓库
    less css 框架介绍
    html的概念
    html
    WEB前端第三十八课——js类和对象,继承,设计模式
    WEB前端第三十七课——jsBOM操作-DataParse、jsEngine、性能、history、道岔、closure
    WEB前端第三十六课——jsBOM操作-window、timer
    WEB前端第三十五课——事件绑定应用案例
    WEB前端第三十四课——js事件对象this、event
  • 原文地址:https://www.cnblogs.com/liuge36/p/12614714.html
Copyright © 2011-2022 走看看