Kafka 安裝配置 windows 下
Kafka 安裝配置 windows 下
標籤(空格分隔): Kafka
Kafka 核心部分需要安裝jdk, zookeeper.
安裝JDK
安裝JDK就不需要講解了,安裝完配置下JAVA_HOME,和Path,將java安裝目錄和執行檔案目錄配置下就ok拉。
安裝地址: 下載
安裝 zookeeper
安裝地址:下載
安裝完zookeeper 需要配置如下資訊:
下載後,解壓放在目錄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)
這是本文最終的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
- 下載地址: 下載
- 安裝配置:
要下載Binary downloads這個型別,不要下載原始檔,這種方便使用。下載後,解壓放在D:\bigdata目錄下。
①進入kafka配置檔案所在目錄,D:\bigdata\kafka_2.11-0.9.0.1\config
②編輯檔案"server.properties",找到並編輯:
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-logs
同樣注意:路徑要麼是"/"分割,要麼是轉義字元"\",這樣會生成正確的路徑(層級,子目錄)。錯誤路徑情況可自行嘗試,資料夾名為這種形式:bigdatakafka_2.11-0.9.0.1kafka-logs
③在server.properties檔案中,zookeeper.connect=localhost:2181代表kafka所連線的zookeeper所在的伺服器IP以及埠,可根據需要更改。本文在同一臺機器上使用,故不用修改。
④kafka會按照預設配置,在9092埠上執行,並連線zookeeper的預設埠2181。
執行Kafka
CMD進入安裝目錄 輸入命令 .\bin\windows\kafka-server-start.bat .\config\server.properties 即可執行
注意:這個裡面會報錯,報找不到kafka.Kafka類
需要進入kafka-class-run檔案裡面改下配置。%ClassPath% 加上雙引號"%ClassPath%"