zoukankan      html  css  js  c++  java
  • kafka_2.13-2.7.0 windows

    https://www.apache.org/dyn/closer.cgi?path=/kafka/2.7.0/kafka_2.13-2.7.0.tgz

    安装包已经内置zookeeper。

    1. 安装JDK

    2.解压安装包文件
     C:kafka_2.13-2.7.0inwindows

    3.运行zookeeper
    打开命令行,执行

    C:kafka_2.13-2.7.0inwindowszookeeper-server-start.bat C:kafka_2.13-2.7.0configzookeeper.properties


    这时大概率报错“找不到或无法加载主类 FilesJavajdk1.8.0_171libdt.jar;C:Program”,不要紧张。

    修改kafka-run-class.bat中的179行,给%CLASSPATH%加上双引号即可,结果如下:

    set COMMAND=%JAVA% %KAFKA_HEAP_OPTS% %KAFKA_JVM_PERFORMANCE_OPTS% %KAFKA_JMX_OPTS% 
    %KAFKA_LOG4J_OPTS% -cp "%CLASSPATH%" %KAFKA_OPTS% %*
       再次执行运行命令,结果为:

    不要关闭这个窗口

    4.运行kafka
    打开新的命令行窗口,执行:

    C:kafka_2.13-2.7.0inwindowskafka-server-start.bat C:kafka_2.13-2.7.0configserver.properties
    执行结果为:

    [2021-03-10 08:30:35,129] INFO Kafka version: 2.7.0 (org.apache.kafka.common.utils.AppInfoParser)
    [2021-03-10 08:30:35,129] INFO Kafka commitId: 448719dc99a19793 (org.apache.kafka.common.utils.AppInfoParser)
    [2021-03-10 08:30:35,129] INFO Kafka startTimeMs: 1615336235127 (org.apache.kafka.common.utils.AppInfoParser)
    [2021-03-10 08:30:35,130] INFO [KafkaServer id=0] started (kafka.server.KafkaServer)
    [2021-03-10 08:30:35,202] INFO [broker-0-to-controller-send-thread]: Recorded new controller, from now on will use broker 0 (kafka.server.BrokerToControllerRequestThread)

    5.创建主题
    让我们创建一个名为“test”的主题,它只包含一个分区,只有一个副本:

    C:kafka_2.13-2.7.0inwindowskafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
    验证主题:

    C:kafka_2.13-2.7.0inwindowskafka-topics.bat --zookeeper localhost:2181 --describe --topic test
    返回:

    Topic:test      PartitionCount:1        ReplicationFactor:1     Configs:
               Topic: test     Partition: 0    Leader: 0       Replicas: 0     Isr: 0

    如果我们运行list topic命令,我们现在可以看到该主题:

    C:kafka_2.13-2.7.0inwindowskafka-topics.bat --list --zookeeper localhost:2181
    返回:

    test

    Microsoft Windows [版本 10.0.19042.804]
    (c) 2020 Microsoft Corporation. 保留所有权利。
    
    C:Usersllskj>C:kafka_2.13-2.7.0inwindowskafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
    Created topic test.
    
    C:Usersllskj>C:kafka_2.13-2.7.0inwindowskafka-topics.bat --zookeeper localhost:2181 --describe --topic test
    Topic: test     PartitionCount: 1       ReplicationFactor: 1    Configs:
            Topic: test     Partition: 0    Leader: 0       Replicas: 0     Isr: 0
    
    C:Usersllskj>list topic
    'list' 不是内部或外部命令,也不是可运行的程序
    或批处理文件。
    
    C:Usersllskj>C:kafka_2.13-2.7.0inwindowskafka-topics.bat --list --zookeeper localhost:2181
    test
    
    C:Usersllskj>
    cmd 测试界面

    6.发送一些消息
    Kafka附带一个命令行客户端,它将从文件或标准输入中获取输入,并将其作为消息发送到Kafka集群。默认情况下,每行将作为单独的消息发送。

    运行生产者,然后在控制台中键入一些消息以发送到服务器。

    C:kafka_2.13-2.7.0inwindowskafka-console-producer.bat --broker-list localhost:9092 --topic test
    发送

    >This is a message
    >This is another message
    7.启动消费者
    Kafka还有一个命令行使用者,它会将消息转储到标准输出。

    C:kafka_2.13-2.7.0inwindowskafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
    得到

  • 相关阅读:
    exchangeNetwork
    VRP OS Management
    filleSystemBasises
    Study_way
    1.MySQL 安装
    7.进程池与线程池
    6.线程
    5.进程 -锁
    4.进程-1
    3.多线程TCP协议与加密方式
  • 原文地址:https://www.cnblogs.com/endv/p/14509378.html
Copyright © 2011-2022 走看看