Kafka Unrecognized VM option 'PrintGCDateStamp

2019-03-18 13:30发布

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 received an error

Unrecognized VM option 'PrintGCDateStamps'

And the kafka server failed to start. This was not being run in a vm, and was being run directly on Ubuntu Server 16.04 with Java properly installed. Any way this can be corrected simply?

6条回答
做自己的国王
2楼-- · 2019-03-18 13:40

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

查看更多
冷血范
3楼-- · 2019-03-18 13:43

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
查看更多
手持菜刀,她持情操
4楼-- · 2019-03-18 13:52

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

查看更多
聊天终结者
5楼-- · 2019-03-18 13:56

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
查看更多
疯言疯语
6楼-- · 2019-03-18 13:59

I am using java 10 and kafka_2.11-0.10.1.0 and I had the same problem.I did not find JAVA_MAJOR_VERSION in the kafka-run-class.sh ,so I reviewed the error. It says "Unrecognized VM option 'PrintGCDateStamps'" This means, Java 10 GC related vm options are changed and Kafka configs are not compatible with it yet. This also confirms my thoughts.

So switching to a Java version < 9 is one solution but if you want to keep using your new java version then instead of removing the whole line containing that parameter , you can remove the specified option. I did that and then "PrintGCTimeStamps" became a problem. I removed that also. So I ended up having the line below : KAFKA_GC_LOG_OPTS="-Xloggc:$LOG_DIR/$GC_LOG_FILE_NAME -verbose:gc -XX:+PrintGCDetails " So this will still print the GC details , but timestamp will not be specified. Zookeeper started without any problem!

查看更多
Summer. ? 凉城
7楼-- · 2019-03-18 14:00

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!

查看更多
登录 后发表回答