无法在 Apache Kafka 中启动 Zookeeper 服务器
Unable to start Zookeeper server in Apache Kafka
我在 kafka_home/bin/windows
(建议 here)。
然后我遇到了与 here 相同的问题,它建议从 kafka 主页启动程序。
从 windows 文件夹启动时出现此错误:
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
有人知道怎么解决吗?
配置文件的默认位置是用相对路径指定的,config/zookeeper.properties
。
Kafka 的目录树看起来有点像这样:
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
中查找其配置,这不存在。
查看启动 ZK 启动脚本的正确命令的现有答案 (Apache Kafka error on windows - Couldnot find or load main class QuorumPeerMain),其中示例命令行明确定义了在哪里可以找到配置文件:
$ 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
这里的问题是 windows bat 脚本没有经过正确测试。
另外文档也没有提到安装scala,java和设置zookeer和Kafka依赖的ENV变量等先决条件。
这是我解决问题的方法,然后 zookeeper ,kafka 服务器已正常启动,运行 很好。
1. 安装scala并设置环境变量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
用 %CD% 替换字符串 %~dp0 的所有条目
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 server/broker 应该可以正常启动
6. 然后我们可以测试创建一个主题,并按照 kafka 快速入门指南中提到的列出主题: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
我发现@MiChael G Noll 的回答很有帮助。我建议遵循 windows:
通过[记住导航到kafka目录的根目录来启动Zookeeper。 windows根目录内容为bin,config,libs,logsetc]:
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
通过.\bin\windows\kafka-server-start.bat .\config\server.properties
启动kafka服务器
当您执行所有这些操作时,请注意,对于 windows,我们从调用相应 .bat
文件的位置导航到 .bin\windows
。
同样,当您想要创建主题或分区时,请记住,在您的 cmd
终端中,您正在从正确的位置调用这些 .bat
文件[而您的根目录是 kafka 目录,因此使用 .\bin
圆点代表根目录,在这个根目录下存放kafka]。
其他相关链接和命令可以在这里找到:
https://www.javaer101.com/en/article/12057273.html
此外,我想为像我这样的初学者指出 - Linux 和 windows 执行之间的并行性
在Linux写消息到console你调用:kafka-console-producer.sh如下:.sh
是扩展名shell 在 linux
中执行
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
It's parallel in windows is observable through .bat
extension, which is executable script on windows console[cmd]: kafka-console-producer.sh
.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test
还要注意kafka中.bat
和.sh
的位置。在 windows 中,它位于 bin\windows
,而在 Linux 中,它直接位于 bin
下的 kafka 目录中。确保相应地调用 !
我在 kafka_home/bin/windows
(建议 here)。
然后我遇到了与 here 相同的问题,它建议从 kafka 主页启动程序。
从 windows 文件夹启动时出现此错误:
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
有人知道怎么解决吗?
配置文件的默认位置是用相对路径指定的,config/zookeeper.properties
。
Kafka 的目录树看起来有点像这样:
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
中查找其配置,这不存在。
查看启动 ZK 启动脚本的正确命令的现有答案 (Apache Kafka error on windows - Couldnot find or load main class QuorumPeerMain),其中示例命令行明确定义了在哪里可以找到配置文件:
$ 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
这里的问题是 windows bat 脚本没有经过正确测试。 另外文档也没有提到安装scala,java和设置zookeer和Kafka依赖的ENV变量等先决条件。
这是我解决问题的方法,然后 zookeeper ,kafka 服务器已正常启动,运行 很好。 1. 安装scala并设置环境变量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 用 %CD% 替换字符串 %~dp0 的所有条目 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 server/broker 应该可以正常启动 6. 然后我们可以测试创建一个主题,并按照 kafka 快速入门指南中提到的列出主题: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
我发现@MiChael G Noll 的回答很有帮助。我建议遵循 windows:
通过[记住导航到kafka目录的根目录来启动Zookeeper。 windows根目录内容为bin,config,libs,logsetc]:
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
通过.\bin\windows\kafka-server-start.bat .\config\server.properties
当您执行所有这些操作时,请注意,对于 windows,我们从调用相应 .bat
文件的位置导航到 .bin\windows
。
同样,当您想要创建主题或分区时,请记住,在您的 cmd
终端中,您正在从正确的位置调用这些 .bat
文件[而您的根目录是 kafka 目录,因此使用 .\bin
圆点代表根目录,在这个根目录下存放kafka]。
其他相关链接和命令可以在这里找到: https://www.javaer101.com/en/article/12057273.html
此外,我想为像我这样的初学者指出 - Linux 和 windows 执行之间的并行性
在Linux写消息到console你调用:kafka-console-producer.sh如下:.sh
是扩展名shell 在 linux
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
It's parallel in windows is observable through .bat
extension, which is executable script on windows console[cmd]: kafka-console-producer.sh
.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test
还要注意kafka中.bat
和.sh
的位置。在 windows 中,它位于 bin\windows
,而在 Linux 中,它直接位于 bin
下的 kafka 目录中。确保相应地调用 !