Java小强个人技术博客站点    手机版
当前位置: 首页 >> 软件 >> Kafka安装Windows版

Kafka安装Windows版

26380 软件 | 2022-6-13

Kafka 是一个由 LinkedIn 开发的分布式消息系统,它于2011年年初开源,现在由著名的 Apache 基金会维护与开发。 Kafka 使用 Scala 实现,被用作 LinkedIn 的活动流和运营数据处理的管道,现在也被诸多互联网企业广泛地用作数据流管道和消息系统, Kafka 是基于消息发布﹣订阅模式实现的消息系统。

kafka.jpg


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

3.2.0 is the latest release. The current stable version is 3.2.0.


kafka服务端配置在server.properties中


监听端口配置,默认就是9092

# The address the socket server listens on. If not configured, the host name will be equal to the value of
# java.net.InetAddress.getCanonicalHostName(), with PLAINTEXT listener name, and port 9092.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
#listeners=PLAINTEXT://:9092

# Listener name, hostname and port the broker will advertise to clients.
# If not set, it uses the value for "listeners".
#advertised.listeners=PLAINTEXT://your.host.name:9092


log.dirs

日志文件修改为自定义的日志目录,这里默认即可,默认在和conf同级的logs下

# A comma separated list of directories under which to store log files
log.dirs=/tmp/kafka-logs


Zookeeper配置

如果你用的是老版本,需要配置zookeeper,但是我下载的最新版后发现其是包含了Zookeeper的

# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=localhost:2181

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=18000


启动,因为Kafka是依赖Zookeeper的,所以要先启动Zookeeper

.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties


然后启动kafka

.\bin\windows\kafka-server-start.bat .\config\server.properties

如果启动kafka失败,并出现以下异常,删除logs文件夹下的meta.properties文件即可


启动kafka-topics

.\bin\windows\kafka-topics.bat --create --bootstrap-server  localhost:2181 --replication-factor 1 --partitions 1 --topic test

启动之后,kafka-topics处于等待创建topic状态,一段时间内如果不createTopic,kafka-topics将自动断开


启动生产者

.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test


启动消费者

.\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test


启动生产者之后就可以发送消息


简易Zookeeper客户端管理工具

http://www.javacui.com/tool/665.html 

Kafka 客户端管理工具 Offset Explorer

https://www.kafkatool.com/


END


推荐您阅读更多有关于“ 安装 Windows 客户端 mq Kafka 消息队列 ”的文章

上一篇:Java实现RSA加密示例代码 下一篇:LUA脚本判断是否为空

猜你喜欢

发表评论: