Kafka安装(windows)

来源:互联网 发布:通过php将base64 编辑:程序博客网 时间:2024/05/17 00:00

Kafka 简介

是一个分布式消息队列,高吞吐量,使用Scala实现。

安装

1.安装JDK

2.下载zookeeper和kafka,解压到某个目录下面,比如我的是 D:\dev

3.修改zookeeper的配置文件,位于D:\dev\zookeeper-3.4.8\conf,把zoo_sample.cfg重命名为zoo.cfg,修改里面的存储目录dataDir和端口号。

# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just example sakes.dataDir=D:\dev\zookeeper-3.4.8\data# the port at which the clients will connectclientPort=2181

4.启动zookeeper(运行bin下面的zkServer,或者修改环境变量path)。

image_1ar0btu8a1ov8neh1unehk11ljm9.png-36.6kB

5.修改kafka配置(server.properties),主要看到里面配置了zookeeper的地址信息,这里在本机。

6.启动kafka server,启动脚本是D:\dev\kafka_2.11-0.10.0.1\bin\kafka-server-start.sh,后面的类似。

D:\dev\kafka_2.11-0.10.0.1>.\bin\windows\kafka-server-start.bat .\config\server.properties

image_1ar0csbjjpdoh7jt6kfggao3m.png-89.8kB

7.创建一个topic,如”test2”。

D:\dev\kafka_2.11-0.10.0.1>.\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test2

image_1ar0cu1tg1b5l1nuk16o9kbild213.png-5.2kB

8.打开消息生成者和消费者,然后可以看到生产者发送的消息会到达消费者。

D:\dev\kafka_2.11-0.10.0.1>.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test2D:\dev\kafka_2.11-0.10.0.1>.\bin\windows\kafka-console-consumer.bat --zookeeperlocalhost:2181 --topic test2

image_1ar0d0g681orl1ocv1sai18dra9c1g.png-48.4kB

小结

慢慢摸索。

0 0