java 启动kafka时输入行太长
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48834927/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The input line is too long when starting kafka
提问by Geha
I'm trying to run Kafka message queue on Windows.
我正在尝试在 Windows 上运行 Kafka 消息队列。
I'm usin this tutorial - https://dzone.com/articles/running-apache-kafka-on-windows-os
我正在使用本教程 - https://dzone.com/articles/running-apache-kafka-on-windows-os
When i try to run it with comand - .\bin\windows\kafka-server-start.bat .\config\server.properties
当我尝试使用命令运行它时 - .\bin\windows\kafka-server-start.bat .\config\server.properties
and i get an error: The input line is too long. The syntax of the command is incorrect.
我收到一个错误: 输入行太长。命令的语法不正确。
kafka location - C:\kafka_2.11-1.0.0
卡夫卡位置 - C:\kafka_2.11-1.0.0
回答by Prashant_M
This is because of the long length of the path because of the folder name 'kafka_2.11-1.0.0'. Just rename the folder to something small, like just 'kafka'.
这是因为文件夹名称“kafka_2.11-1.0.0”导致路径很长。只需将文件夹重命名为较小的名称,例如“kafka”。
回答by Midiman
The Problem
问题
The kafka-run-class.bat
file performs a bunch of CLASSPATH :concat calls that make the CLASSPATH very long.
该kafka-run-class.bat
文件执行了一堆 CLASSPATH :concat 调用,这使得 CLASSPATH 很长。
Depending on your environment, too long: Windows cmd.exe environment has a limit of 8191 characters.
根据您的环境,太长:Windows cmd.exe 环境有 8191 个字符的限制。
Solutions
解决方案
Edit kafka-run-class.bat
so that ...
编辑kafka-run-class.bat
以便...
- make it so that CLASSPATH is not used or set elsewhere
- make paths shorter so that concat produces a string smaller than than 8191 characters
- make concat use the whole folder instead of every single jar (via
libs/*
)
- 使其不使用 CLASSPATH 或在别处设置
- 使路径更短,以便 concat 生成小于 8191 个字符的字符串
- 使 concat 使用整个文件夹而不是每个 jar(通过
libs/*
)
Example
例子
Here is an example of an edit to kafka-run-class.bat
(source) that uses the 2nd approach:
以下是使用第二种方法对kafka-run-class.bat
( source)进行编辑的示例:
replace ...
代替 ...
rem Classpath addition for release
for %%i in ("%BASE_DIR%\libs\*") do (
call :concat "%%i"
)
... by this ...
... 这样 ...
rem Classpath addition for release
call :concat "%BASE_DIR%\libs\*;"
回答by Adam Bodrogi
I have copied everything to C:/tools/kafka and it works fine. The problem was indeed the too long path to kafka.
我已将所有内容复制到 C:/tools/kafka 并且它工作正常。问题确实是 kafka 的路径太长了。
回答by Lukas Maruniak
Windows command-line has issues with long command execution. Use Powershell instead.
Windows 命令行存在长命令执行问题。请改用 Powershell。
回答by drt
Above both options didn't work for me.
以上两个选项对我都不起作用。
I have just moved an unzipped directory to C:/ drive and started power shell in Administratormode and tried the desired commands, the zookeeper and broker started smoothly.
我刚刚将解压后的目录移动到 C:/ 驱动器并以管理员模式启动 power shell并尝试了所需的命令,zookeeper 和 broker 顺利启动。
回答by YESHWANTH LN
put all the files in other drive like D: or E: and run the command
将所有文件放在其他驱动器中,例如 D: 或 E: 并运行命令
回答by user1416932
Rename the kafka folder to some shorter name like kafka2. Open a new command prompt (DO not use existing/opened command prompt)
将 kafka 文件夹重命名为更短的名称,如 kafka2。打开一个新的命令提示符(不要使用现有/打开的命令提示符)
回答by Kar
I tried extracting the downloaded Kafka zip file contacts
我尝试提取下载的 Kafka zip 文件联系人
C:\Kafka and ran the Kafka-server-start.bat
from the command prompt (don't run the command prompt as administrator) and that worked.
从命令提示符(不要以管理员身份运行命令提示符)并且有效。
Running the command prompt as administrator was causing the problem for me.
以管理员身份运行命令提示符给我带来了问题。
回答by John Fantastico
Place kafka close to the root of your drive so that the path to it is very short.
将 kafka 放在靠近驱动器根部的位置,以便它的路径非常短。
When you run those Kafka batch files included in the windows directory, they muck with your environment variables (the classpath one) and can create a very long input line to actually run the command/jar.
当您运行 windows 目录中包含的那些 Kafka 批处理文件时,它们会与您的环境变量(类路径变量)混淆,并且可以创建一个很长的输入行来实际运行命令/jar。
Also as some others pointed out, ensure you downloaded the binary (yes even though on the Kafka site it is called the Scala binary and there's no mention of Windows anywhere, which can confuse people), not the source code. Also confusing to the lay-user, the source distribution looks similar to the binary distribution when uncompressed, it has all the batch files for example but they won't run.
同样正如其他一些人指出的那样,确保您下载了二进制文件(是的,即使在 Kafka 站点上它被称为 Scala 二进制文件,并且在任何地方都没有提到 Windows,这可能会使人们感到困惑),而不是源代码。同样令外行用户感到困惑的是,源代码分发在未压缩时看起来类似于二进制分发,例如,它具有所有批处理文件,但它们不会运行。