• kafka在windows下单机版搭建


    kafka在windows下单机版搭建

    1.win本地单机版搭建

    1.1安装zookeeper环境

    • 下载地址

      Apache Downloads

    • 添加配置文件

      在config目录下复制一份zoo_sample.cfg文件到同级目录,然后更改名称为zoo.cfg

    • 添加如下配置内容

      tickTime=2000
      initLimit=10
      syncLimit=5
      clientPort=2181
      dataDir=D:\\environment\\apache-zookeeper-3.5.10-bin\\data
      dataLogDir=D:\\environment\\apache-zookeeper-3.5.10-bin\\log
      admin.serverPort=9999
      
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8

      主要制定data和log路径已经端口号

    • 配置系统环境变量

      ZOOKEEPER_HOME 值对应zookeeper目录

      path添加一个 %ZOOKEEPER_HOME%\bin

    • 启动bin目录下zkServer.cmd

      注:如果遇到闪退可以百度,很多解决办法

    2.2安装kafka环境

    • 下载地址

      Apache Kafka

    • 修改config目录下的server.properties

      broker.id=0
      
      num.network.threads=3
      
      # The number of threads that the server uses for processing requests, which may include disk I/O
      num.io.threads=8
      
      # The send buffer (SO_SNDBUF) used by the socket server
      socket.send.buffer.bytes=102400
      
      # The receive buffer (SO_RCVBUF) used by the socket server
      socket.receive.buffer.bytes=102400
      
      # The maximum size of a request that the socket server will accept (protection against OOM)
      socket.request.max.bytes=104857600
      
      
      log.dirs=D:\environment\kafka_2.12-2.2.0\logs
      
      num.partitions=1
      
      num.recovery.threads.per.data.dir=1
      
      
      offsets.topic.replication.factor=1
      transaction.state.log.replication.factor=1
      transaction.state.log.min.isr=1
      log.retention.hours=168
      
      log.segment.bytes=1073741824
      
      log.retention.check.interval.ms=300000
      
      zookeeper.connect=localhost:2181
      
      zookeeper.connection.timeout.ms=6000
      
      group.initial.rebalance.delay.ms=0
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 30
      • 31
      • 32
      • 33
      • 34
      • 35
      • 36
      • 37
      • 38

      由于是单机版,所以主要修改log.dirs路径,zookeeper.connect值

    • 启动kafka

      第一步:进入bin下的windows

      第二步:在路径框输入cmd

      第三步:在cmd中输入kafka-server-start.bat ..\..\config\server.properties

    2.3测试安装是否成功(以案例形式展示)

    2.3.1创建一个topic 取名test
    在bin\windows目录下打开cmd
    .\kafka-console-producer.bat --broker-list localhost:9998 --topic test
    
    • 1
    • 2
    2.3.2创建一个消费者
    在bin\windows目录下打开cmd
     .\kafka-console-consumer.bat --bootstrap-server localhost:9998 --from-beginning --topic test
    
    • 1
    • 2
    2.3.3成功结果

    在生产者窗口输入内容,消费者窗口就会收到消息即是成功

  • 相关阅读:
    Codeforces Round #810 (Div. 2) D. Rain (线段树差分)
    Yii post()追加数据,模块之间的调用runAction
    Vue实现动态组件
    Pycharm在进行debug时出现collecting data如何解决?
    Python eval()函数详解
    查看linux下dns信息并修改
    python DVWA文件上传POC练习
    安防视频监控平台EasyNVR无法控制云台,该如何解决?
    让历史文化“活”起来,北京河图“万象中轴”助力打造北京城市金名片
    2、Shell 脚本入门
  • 原文地址:https://blog.csdn.net/qq_39594037/article/details/126704921