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.0\bin\windows

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

C:\kafka_2.13-2.7.0\bin\windows\zookeeper-server-start.bat C:\kafka_2.13-2.7.0\config\zookeeper.properties


这时大概率报错“找不到或无法加载主类 Files\Java\jdk1.8.0_171\lib\dt.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.0\bin\windows\kafka-server-start.bat C:\kafka_2.13-2.7.0\config\server.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.0\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
验证主题:

C:\kafka_2.13-2.7.0\bin\windows\kafka-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.0\bin\windows\kafka-topics.bat --list --zookeeper localhost:2181
返回:

test

Microsoft Windows [版本 10.0.19042.804]
(c) 2020 Microsoft Corporation. 保留所有权利。

C:\Users\llskj>C:\kafka_2.13-2.7.0\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
Created topic test.

C:\Users\llskj>C:\kafka_2.13-2.7.0\bin\windows\kafka-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:\Users\llskj>list topic
'list' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

C:\Users\llskj>C:\kafka_2.13-2.7.0\bin\windows\kafka-topics.bat --list --zookeeper localhost:2181
test

C:\Users\llskj>
cmd 测试界面

相关文章:

  • 2021-09-19
  • 2021-06-08
  • 2022-12-23
  • 2021-04-09
  • 2021-05-11
  • 2021-08-07
猜你喜欢
  • 2021-04-04
  • 2022-12-23
  • 2021-07-15
  • 2021-10-27
  • 2021-11-03
  • 2021-05-25
  • 2022-12-23
相关资源
相似解决方案