Kafka安裝(windows)

Kafka 簡介

是一個分佈式消息隊列,高吞吐量,使用Scala實現。

安裝

1.安裝JDK

2.下載zookeeperkafka,解壓到某個目錄下面,比如我的是 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 connect
clientPort=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 l
ocalhost: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-lis
t localhost:9092 --topic test2

D:\dev\kafka_2.11-0.10.0.1>.\bin\windows\kafka-console-consumer.bat --zookeeper
localhost:2181 --topic test2

image_1ar0d0g681orl1ocv1sai18dra9c1g.png-48.4kB

小結

慢慢摸索。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章