Elasticsearch 7.2.0. homebrew install on mac java error on startup fail

$ elasticsearch

Exception in thread "main" java.lang.RuntimeException: starting java failed with [1]

output:

[0.002s][error][logging] Error opening log file 'logs/gc.log': No such file or directory

[0.002s][error][logging] Initialization of output 'file=logs/gc.log' using options 'filecount=32,filesize=64m' failed.

error:

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.

Invalid -Xlog option '-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m', see error log for details.

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

at org.elasticsearch.tools.launchers.JvmErgonomics.flagsFinal(JvmErgonomics.java:111)

at org.elasticsearch.tools.launchers.JvmErgonomics.finalJvmOptions(JvmErgonomics.java:79)

at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:57)

at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:89)
<

I'm not able to reproduce this locally. Could you please provide some more information about your environment? In particular, whether you have JAVA_HOME set (and if so what version of java), as well as your MacOS version?

It is MacOS Mojave 10.14.3

$ echo $JAVA_HOME
/usr/bin/java
$ java -version
java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)

But the interesting thing is that the error seems to indicate OpenJDK:

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Invalid -Xlog option '-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m', see error log for details.

[0.002s][error][logging] Error opening log file 'logs/gc.log': No such file or directory
seems to indicate missing logs folder somewhere

I followed
Announcing the official Elastic Homebrew tap for macOS | Elastic Blog,
Installed with:
brew tap elastic/tap
brew install elasticsearch-full

According to the recipe, this should install elasticsearch into:
/usr/local/Cellar/elasticsearch-full/7.2.0/
and true, there is only bin and libexec directories there.
Should the logs directory be here?

so, I got it started, but still hack
export JAVA_HOME=/usr/bin/java elasticsearch
could not find java in JAVA_HOME or bundled at /usr/bin/java/bin/java

peeling it down:
$export JAVA_HOME=/usr . (somewhat unusual, but works)

$ elasticsearch
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
future versions of Elasticsearch will require Java 11; your Java version from [/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/jre] does not meet this requirement
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file logs/gc.log due to No such file or directory
[2019-07-29T13:26:54,308][WARN ][o.e.c.l.LogConfigurator ] [flazar-mac] Some logging configurations have %marker but don't have %node_name. We will automatically add %node_name to the pattern to ease the migration for users who customize log4j2.properties but will stop this behavior in 7.0. You should manually replace %node_name with [%node_name]%marker in these locations:
/usr/local/etc/elasticsearch/log4j2.properties

...

So, the brew install

  • has JVM options incompatible with the embedded (OpenJDK) VM
  • missing creating the the logs folder (but that might be ok, it might have been created at first run.
  • elasticsearch is checking for java in the $JAVA_HOME/bin/java. but when it starts it is looking in the $JAVA_HOME, and when it doesn't find it, goes for the "system provided"
  • FYI /usr/bin/java is a link to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java, so $JAVA_HOME should be /System/Library/Frameworks/JavaVM.framework/Versions/Current/, except that it doesn't have a bin/java, it has Commands/java

So there is no 'good' $JAVA_HOME spec, only one that gets you by...

unless I'm missing something....

I hit a similar issue with -Xlog, brew and Elasticsearch 7.3. Removing lines referring to -Xlog from /usr/local/etc/elasticsearch/jvm.options resolved it.

It looks like that file persisted from earlier elasticsearch installs (6.x?) and was now incompatible with 7.3, so I just uninstalled ES7.3, removed /usr/local/etc/elasticsearch completely and reinstalled ES7.3 to get a fresh start.

8 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.