Kafka Unrecognized VM option 'PrintGCDateStamps'

前端 未结 7 1252
梦毁少年i
梦毁少年i 2021-02-02 12:12

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

相关标签:
7条回答
  • 2021-02-02 12:35

    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

    0 讨论(0)
  • 2021-02-02 12:44

    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
    
    0 讨论(0)
  • 2021-02-02 12:44

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

    0 讨论(0)
  • 2021-02-02 12:45

    Like the other answers -- I got this to work on Java 9. Had to make the following changes:

    1. Edit the file bin/kafka-run-class.sh

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

    1. Remove the 2 flags : -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps and save the file.

    2. Kafka should start okay on Java 9

    0 讨论(0)
  • 2021-02-02 12:54

    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!

    0 讨论(0)
  • 2021-02-02 12:57

    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
    
    0 讨论(0)
提交回复
热议问题