Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch 7.3 upgrade with homebrew

I was using Elasticsearch 6.8 via homebrew, and I was trying to upgrade to 7.3. Previously, on 6.8 I already got a warning about a log file that did not exist, but the server would still run - so I did nothing.

Now with 7.3, I get an error and the server won’t run:

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 tried creating the dir/file where elasticsearch was installed, but that did not work for me (or i did something wrong).

like image 541
Niels Lucas Avatar asked Aug 13 '19 14:08

Niels Lucas


1 Answers

Reference: https://onecompiler.com/questions/3uwszcf3x/homebrew-installed-elasticsearch-failing-to-start

I have fixed this by changing the relative logs/gc.log path to an absolute path. Follow the below steps to solve the issue

  1. Open jvm.options file which is located at /usr/local/etc/elasticsearch/jvm.options

  2. Change the relative path to an absolute path from the following

# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m

to

# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=/usr/local/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m
  1. Restart elasticsearch $ brew services restart elasticsearch-full or just start it without daemon - $ elasticsearch
like image 152
Xiting Avatar answered Sep 24 '22 09:09

Xiting