消息队列

Windows 运行kafka2.11

2019-02-18  本文已影响14人  nickbi

一.安装zookeeper

zookeeper下载地址下载地址:https://zookeeper.apache.org/releases.html

二.安装kafka

kafka下载地址:https://kafka.apache.org/downloads

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\DELL>D:

D:\>cd soft\kafka_2.11-1.0.1

D:\soft\kafka_2.11-1.0.1>.\bin\windows\kafka-server-start.bat .\config\server.pr
operties

三.创建生产者及消费者进行测试

1.创建kafka topic
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\DELL>d:

D:\>cd soft\kafka_2.11-1.0.1

D:\soft\kafka_2.11-1.0.1>.\bin\windows\kafka-topics.bat --create --zookeeper loc
alhost:2181 --replication-factor 1 --partitions 1 --topic test
Created topic "test".

D:\soft\kafka_2.11-1.0.1>
2.启动生产者
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\DELL>d:

D:\>cd soft\kafka_2.11-1.0.1

D:\soft\kafka_2.11-1.0.1>.\bin\windows\kafka-console-producer.bat --broker-list
localhost:9092 --topic test
>hello kafka!
>
3.启动消费者

官方将使用“boostrap-server”命令替代“zookeeper”

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\DELL>d:

D:\>cd soft\kafka_2.11-1.0.1

# 方法1
D:\soft\kafka_2.11-1.0.1>.\bin\windows\kafka-console-consumer.bat --zookeeper lo
calhost:2181 --topic test
Using the ConsoleConsumer with old consumer is deprecated and will be removed in
 a future major release. Consider using the new consumer by passing [bootstrap-s
erver] instead of [zookeeper].
2
1
# 方法2:官方将使用“boostrap-server”命令替代“zookeeper”
D:\soft\kafka_2.11-1.0.1>.\bin\windows\kafka-console-consumer.bat --bootstrap-se
rver localhost:9092 --topic test
1
2

至此,kafka2.11在windows中就可以运行,如下更新详细的信息,请访问官方教程

上一篇 下一篇

猜你喜欢

热点阅读