2017-05-30 70 views
1

我在kafka_home/bin/windows(建議here)。 然後我遇到了與here相同的問題,它建議從kafka家啓動程序。無法在Apache Kafka中啓動Zookeeper服務器

INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig) 
[2014-08-21 11:53:55,748] FATAL Invalid config, exiting abnormally (org.apache.zookeeper.server.quorum.QuorumPeerMain) 
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing config/zookeeper.properties 
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:110) 
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:99) 
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:76) 
Caused by: java.lang.IllegalArgumentException: config/zookeeper.properties file is missing 
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:94) 
    ... 2 more 
Invalid config, exiting abnormally 

有誰知道如何解決這個問題: 我從Windows文件夾中運行時出現此錯誤?

+0

的痕跡說,配置文件丟失 –

+0

確保配置文件是在正確的目錄位置 –

+0

它是,它位於kafka_home /配置/ 。仍然有錯誤 – sirdan

回答

1

配置文件的默認位置用相對路徑config/zookeeper.properties指定。

卡夫卡的目錄樹看起來有點像這樣:

bin/ 
    | 
    +-- zookeeper-server-start.sh 
    | 
    +-- windows/ 
     | 
     +-- zookeeper-server-start.bat 
config/ 
    | 
    +-- zookeeper.properties 

所以,如果你硬是bin/windows/目錄內,然後再從那裏zookeeper-server-start.bat,ZK的啓動腳本將有效地尋找它的配置在bin/windows/config/zookeeper.properties,這不存在。

看看正確的命令現有的答案(Apache Kafka error on windows - Couldnot find or load main class QuorumPeerMain)啓動ZK啓動腳本,在命令行例子明確定義在哪裏可以找到配置文件:

$ cd bin/windows 
$ zookeeper-server-start.bat ../../config/zookeeper.properties 

# The below will NOT work (explanation is above) 
$ cd bin/windows 
$ zookeeper-server-start.bat 
+0

在Apache Kafka網站的快速入門指南的第一行中,清楚地寫道,對於Windows用戶,您必須位於根文件夾中,然後執行bin \ windows \ ...,然後執行其餘的命令。 無論如何,謝謝。 – sirdan

+0

是的,但在上面的問題中,您明確表示您做了一些不同的事情:您不在根文件夾中,然後執行'bin \ windows \ zookeeper-server-start。蝙蝠「(這將工作),但相反,你是在錯誤的目錄:」我在'kafka_home/bin/windows'「。 –

+0

我知道,我的意見是澄清我發現了我的一個錯誤。 – sirdan

1

這裏的問題是windows bat腳本沒有正確測試。 此外,文檔還沒有提到安裝scala,java和設置zookeer和Kafka依賴的ENV變量等先決條件。

這是我做了什麼來解決問題,然後zookeeper,kafka服務器已正常啓動,運行良好。 1.安裝scala並設置env變量SCALA_HOME,SCALA_VERSION,SCALA_BINARY_VERSION。將SCALA_HOME \ bin添加到PATH。 2.安裝java並設置JAVA_HOME並將JAVA_HOME \ bin添加到PATH。 3.更正文件\ bin \ windows \ zookeeper-server-start.bat和\ bin \ windows \ kafka-run-class.bat BY 替換所有條目字符串%〜dp0 WITH%CD% 4. CD並運行命令來啓動ZOOKEER:bin \ windows \ zookeeper-server-start.bat config \ zookeeper.properties 例如 - > D:\ apps \ kafka_2.12-0.11.0.1> bin \ windows \ zookeeper-server-start .bat config \ zookeeper.properties Zookeeper應該正常啓動 5 CD並運行命令以啓動KAFKA服務器:bin \ windows \ kafka-server-start.bat config \ server.properties 例如 - > D:\ apps \ kafka_2 .12-0.11.0.1> bin \ windows \ kafka-server-start.bat config \ server.properties kafka服務器/代理應該正常啓動 6.然後,我們可以測試創建主題並將主題列爲我ntioned在卡夫卡快速入門指南她:https://kafka.apache.org/quickstart

D:\apps\kafka_2.12-0.11.0.1>bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test2 
Created topic "test2". 

D:\apps\kafka_2.12-0.11.0.1>bin\windows\kafka-topics.bat --list --zookeeper localhost:2181 
test 
test2 

enter image description here