標籤(空格分隔): Kafkahtml
Kafka 內核部分須要安裝jdk, zookeeper.java
安裝JDK就不須要講解了,安裝完配置下JAVA_HOME,和Path,將java安裝目錄和運行文件目錄配置下就ok拉。
安裝地址: 下載apache
安裝地址:下載
安裝完zookeeper 須要配置以下信息:windows
下載後,解壓放在目錄D:\bigdata(本文所用的目錄)下,關於zookeeper以及kafka的目錄,路徑中最好不要出現空格,好比D:\Program Files,儘可能別用,運行腳本時會有問題。服務器
1.進入zookeeper的相關設置所在的文件目錄,例如本文的:D:\bigdata\zookeeper-3.4.10\conf
2.將"zoo_sample.cfg"重命名爲"zoo.cfg"
3.打開zoo.cfg(至於使用什麼編輯器,根據本身喜愛選便可),找到並編輯:
dataDir=/tmp/zookeeper to D:/bigdata/zookeeper-3.4.10/data或 D:\bigdata\zookeeper-3.4.10\data(路徑僅爲示例,具體可根據須要配置)
這裏注意,路徑要麼是"/"分割,要麼是轉義字符"\",這樣會生成正確的路徑(層級,子目錄)。
4.與配置jre相似,在系統環境變量中添加:
a.系統變量中添加ZOOKEEPER_HOME=D:\bigdata\zookeeper-3.4.10
b.編輯系統變量中的path變量,增長%ZOOKEEPER_HOME%\bin
5在zoo.cfg文件中修改默認的Zookeeper端口(默認端口2181)oracle
這是本文最終的zoo.cfg文件的內容:編輯器
# The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=D:/bigdata/zookeeper-3.4.10/data #dataDir=D:\\bigdata\\zookeeper-3.4.10\\data # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval
①進入kafka配置文件所在目錄,D:\bigdata\kafka_2.11-0.9.0.1\configide
②編輯文件"server.properties",找到並編輯:ui
log.dirs=/tmp/kafka-logs to log.dirs=D:/bigdata/kafka_2.11-0.9.0.1/kafka-logs 或者 D:\bigdata\kafka_2.11-0.9.0.1\kafka-logsthis
一樣注意:路徑要麼是"/"分割,要麼是轉義字符"\",這樣會生成正確的路徑(層級,子目錄)。錯誤路徑狀況可自行嘗試,文件夾名爲這種形式:bigdatakafka_2.11-0.9.0.1kafka-logs
③在server.properties文件中,zookeeper.connect=localhost:2181表明kafka所鏈接的zookeeper所在的服務器IP以及端口,可根據須要更改。本文在同一臺機器上使用,故不用修改。
④kafka會按照默認配置,在9092端口上運行,並鏈接zookeeper的默認端口2181。
CMD進入安裝目錄 輸入命令 .\bin\windows\kafka-server-start.bat .\config\server.properties 便可運行
注意:這個裏面會報錯,報找不到kafka.Kafka類 須要進入kafka-class-run文件裏面改下配置。%ClassPath% 加上雙引號"%ClassPath%"