Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The input line is too long when starting kafka

I'm trying to run Kafka message queue on Windows.

I'm usin this tutorial - 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

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

like image 587
Geha Avatar asked Feb 16 '18 21:02

Geha


13 Answers

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'.

like image 97
Prashant_M Avatar answered Oct 06 '22 04:10

Prashant_M


The Problem

The kafka-run-class.bat file performs a bunch of CLASSPATH :concat calls that make the CLASSPATH very long.

Depending on your environment, too long: Windows cmd.exe environment has a limit of 8191 characters.

Solutions

Edit kafka-run-class.bat so that ...

  1. make it so that CLASSPATH is not used or set elsewhere
  2. make paths shorter so that concat produces a string smaller than than 8191 characters
  3. make concat use the whole folder instead of every single jar (via libs/*)

Example

Here is an example of an edit to kafka-run-class.bat (source) that uses the 2nd approach:

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\*;"
like image 25
Midiman Avatar answered Oct 06 '22 04:10

Midiman


Just moving the Kafka path to a much smaller root path solved the issue. For e.g. "C:\Kafka"

like image 28
Anand Avatar answered Oct 06 '22 03:10

Anand


Above both options didn't work for me.

I have just moved an unzipped directory to C:/ drive and started power shell in Administrator mode and tried the desired commands, the zookeeper and broker started smoothly.

like image 35
drt Avatar answered Oct 06 '22 02:10

drt


Place kafka close to the root of your drive so that the path to it is very short.

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.

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.

like image 26
John Fantastico Avatar answered Oct 06 '22 02:10

John Fantastico


Windows command-line has issues with long command execution. Use Powershell instead.

like image 30
Lukas Maruniak Avatar answered Oct 06 '22 03:10

Lukas Maruniak


put all the files in other drive like D: or E: and run the command

like image 41
YESHWANTH LN Avatar answered Oct 06 '22 03:10

YESHWANTH LN


I have copied everything to C:/tools/kafka and it works fine. The problem was indeed the too long path to kafka.

like image 26
Adam Bodrogi Avatar answered Oct 06 '22 04:10

Adam Bodrogi


For me, it worked only after keeping the Kafka folder right under C directory, so the path looked like C:\Kafka. I am sure this will work.

like image 43
Shridhar Kulkarni Avatar answered Oct 06 '22 02:10

Shridhar Kulkarni


The input line is too long when starting kafka

I tried below command but gives me same error

C:\kafka>.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties

This happens because path gets append in classpath when we are continuously executing same command on same cmd.

Close your command prompt and open once again and then start zookeeper server.

like image 21
Priyanka Bauskar Avatar answered Oct 06 '22 04:10

Priyanka Bauskar


For Windows just keep Kafka Folder path short For eg - D/dev/kafka/bin/windows

like image 28
Gautam Mishra Avatar answered Oct 06 '22 02:10

Gautam Mishra


Kafka folder/directory path length needs to be decreased. Use short folder/directory path then it should start working.

like image 2
Chetan Hegde Avatar answered Oct 06 '22 04:10

Chetan Hegde


Closing Zookeeper and Kafka cmd window and reopening it again worked for me. I tried all options above except powershell.

like image 1
Sonal Chauhan Avatar answered Oct 06 '22 03:10

Sonal Chauhan