I installed Kafka on a remote server, and when I tried to run
~/kafka/bin/zookeeper-server-start.sh ~/kafka/config/zookeeper.properties
And I r
Actually, Kafka works fine with newer versions of Java. I had the same problem, and found an error in the kafka/bin/kafka-run-class.sh
script, where the Java version was incorrectly parsed.
This line grabs too much of the version string:
JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([^.-]*).*"/\1/p')
This makes the if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]]
condition fail to identify the correct Java version, and adds some unsupported GC options.
Changing the line above to this solved my problem:
JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([^.-]*).*/\1/p')
I have reported this as an issue with Kafka. The issue can be found here: https://issues.apache.org/jira/browse/KAFKA-6855
EDIT: There is a committed fix for this: https://github.com/apache/kafka/commit/e9f86c3085fa8b65e77072389e0dd147b744f117
Same issue on Ubuntu 16.04 with oracle jdk 9 installed, I have also tried openjdk 1.9 and got the same error. But when I try other version jdk, I found that oracle jdk 8 and openjdk 1.8 are both ok.
So just check out what version of java you're using, maybe you can install or switch to other version of jdk by:
update-alternatives --display java
update-alternatives --config java
java -version
@Mitchell Tracy, i know this is a bit older thread, just putting it out there my findings on the same issue i encountered if anyone's running into same issue.
I had jdk-9 (Early Access) pointing in my $java_home, i got all kinds of errors per se, Unrecognized VM option 'PrintGCDateStamps', -loggc deprecreated, -cp requires a classpath specified
, and so forth.
Moved the jdk-9 out of the way from $java_home with a command (sudo mv jdk1.8.0.jdk ~/Documents) and restarted the terminal, It worked like a charm! I was able to fire up zookeeper-server-start and kafka. I hope this helps.
Like the other answers -- I got this to work on Java 9. Had to make the following changes:
Edit the file bin/kafka-run-class.sh
Near the end of the file (around line 248) find the following block:
if [ "x$GC_LOG_ENABLED" = "xtrue" ]; then
GC_LOG_FILE_NAME=$DAEMON_NAME$GC_FILE_SUFFIX
KAFKA_GC_LOG_OPTS="-Xloggc:$LOG_DIR/$GC_LOG_FILE_NAME -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps "
fi
Remove the 2 flags : -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps
and save the file.
Kafka should start okay on Java 9
So I found an answer and wanted to post it in case anyone else had this problem. In the kafka/bin/kafka-run-class.sh at the very bottom there is a part where it says
exec $JAVA $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_OPTS -cp $CLASSPATH $KAFKA_OPTS "$@"
Delete the $KAFKA_GC_LOG_OPTS option. Might be a hack, but at least it gets the kafka zookeeper server to start!
As of now, the Kafka's default package has errors with Java 9. The easiest solution is to roll back to java8.
sudo add-apt-repository ppa:webupd8team/java
sudo apt update; sudo apt install oracle-java8-installer
sudo apt install oracle-java8-set-default