Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

jvm.options: Error opening log file 'logs/gc.log': No such file or directory #249

Closed
jpcarey opened this issue Dec 18, 2018 · 15 comments
Closed

Comments

@jpcarey
Copy link

jpcarey commented Dec 18, 2018

Environment

Server 2012 R2 Standard
Oracle Java 10.0.1+10, Java HotSpot(TM) 64-Bit Server VM

Steps to reproduce the behaviour

New install of elasticsearch-6.5.2.msi. I noticed the issue when using vagrant + ansible to provision the system. I uninstalled, and reinstalled using the UI (and mainly defaults, basic license, and untick start server [as I believe this causes the install to fail, since the service can't start]). Starting elasticsearch manually through powershell (or command prompt), I get the following error:

PS C:\Users\vagrant> cd 'C:\Program Files\Elastic\Elasticsearch\6.5.2\bin'
PS C:\Program Files\Elastic\Elasticsearch\6.5.2\bin> .\elasticsearch.exe
[Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
0.002s][error][logging                  ] [] Invalid -Xlog option '-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m'
Error opening log file 'logs/gc.log': No such file or directory

If I edit the C:\ProgramData\Elastic\Elasticsearch\config\jvm.options file, and change line 105 from safepoint:file=logs/gc.log -> safepoint:file=/ProgramData/Elastic/Elasticsearch/log/gc.log I can successfully start elasticsearch.

I suspect that this location should actually resolve to %ALLUSERSPROFILE%/Elastic/Elasticsearch/log, since that is where other elasticsearch log will go to. The jvm needs to know the right path in this case, since it can't read the log location from the elasticsearch.yml until the process has already started.

There are other relative paths in the jvm.options as well:

  • line 99: 8:-Xloggc:logs/gc.log This would likely cause the same issue as described above, if I was using Java 8. Since I am not, this seems to be ignored and elasticsearch can start.
  • line 91: -XX:ErrorFile=logs/hs_err_pid%p.log. This doesn't prevent elasticsearch from starting, but likely means that a heap dump on OOM will fail due to the relative path.

related issues:

cc: @Mpdreamz

@jpcarey jpcarey pinned this issue Dec 18, 2018
@IanKemp
Copy link

IanKemp commented Jan 9, 2019

Would be nice if you guys could fix this pronto... somewhat unprofessional to download the software, follow the steps it tells you, and then it doesn't work. Yes, I know the MSI is beta, but a modicum of testing would have been nice.

@Mpdreamz
Copy link
Member

Sorry about the delay in updating here. Our CI runs against Java 8 and does not surface this error. Will look into getting this fixed again this week.

@AArayeshi
Copy link

I have same issue to install and run elastic search on Windows 10.
I have fixed this issue by following steps:

  • Installing jdk8 before installing elastic
  • In elastic install as a service options I have selected "start Elasticsearch manually as needed"
  • changing vm size to 1G
  • Manually creating logs folder inside C:\Program Files\Elastic\Elasticsearch\6.5.4
  • Granting full security permission for all users to new log folder
  • Then run elastic by command line

@pateldips
Copy link

I have same issue on Windows 7. OpenJDK 11.0.2 and ES 6.6.0. Used .msi to install.
Used below to fixed.

  • Manually created log folder in C:\Program Files\Elastic\Elasticsearch\6.6.0

@jagzuk
Copy link

jagzuk commented Feb 8, 2019

I resolved this on Windows 10 as follows:

  1. Manually create C:\Program Files\Elastic\Elasticsearch\6.6.0\logs
  2. Grant LOCAL_SERVICE full control of \logs

@codebrain
Copy link
Contributor

@jpcarey @Mpdreamz

Can confirm the steps given above to replicate the issue:

  1. Install Java JRE 10.0.1
  2. Set JAVA_HOME to C:\Program Files\Java\jre-10.0.1
  3. Download and install elasticsearch-6.5.2.msi - no need to install as a service, default settings everywhere.
  4. Run elasticsearch.exe, see the following error:
C:\Program Files\Elastic\Elasticsearch\6.5.2\bin\elasticsearch.exe
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[0.003s][error][logging                  ] [] Invalid -Xlog option '-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m'
Error opening log file 'logs/gc.log': No such file or directory
  1. Modify jvm.options and fix all relative paths of logs\ to full path of /ProgramData/Elastic/Elasticsearch/logs/
  2. Run elasticsearch.exe
  3. Confirm running Elasticsearch server

Currently working on a fix; new installations will modify the jvm.options file to perform the path rewrite.

@IanKemp
Copy link

IanKemp commented Feb 27, 2019

Thank you guys!

@codebrain codebrain unpinned this issue Feb 27, 2019
@lugq1990
Copy link

I face with the same problem in windows, I create the logs folder in parent folder of ES, I run the elasticsearch.exe with admin user then it works for me.

@russcam
Copy link
Contributor

russcam commented Aug 19, 2019

@lugq1990 This has been fixed in 7.2.1 and 7.3.0. Would you be able to try with one of those versions?

@nijanthan0
Copy link

I have the same issue..But in mac osX

`Macintosh:~ sura_developers$ elasticsearch
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file logs/gc.log due to No such file or directory

[2019-08-20T16:18:11,493][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/local/var/lib/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.8.2.jar:6.8.2]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.8.2.jar:6.8.2]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.8.2.jar:6.8.2]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.8.2.jar:6.8.2]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.8.2.jar:6.8.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.8.2.jar:6.8.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.8.2.jar:6.8.2]
Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/local/var/lib/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
at org.elasticsearch.env.NodeEnvironment.(NodeEnvironment.java:300) ~[elasticsearch-6.8.2.jar:6.8.2]
at org.elasticsearch.node.Node.(Node.java:296) ~[elasticsearch-6.8.2.jar:6.8.2]
at org.elasticsearch.node.Node.(Node.java:266) ~[elasticsearch-6.8.2.jar:6.8.2]
at org.elasticsearch.bootstrap.Bootstrap$5.(Bootstrap.java:212) ~[elasticsearch-6.8.2.jar:6.8.2]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.8.2.jar:6.8.2]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.2.jar:6.8.2]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.2.jar:6.8.2]
... 6 more`

@nijanthan0
Copy link

Please help me to solve this problem.
I installed elasticsearch version 6.8.2
then jvm 1.8.0_221.jdk

@vaelinn123
Copy link

vaelinn123 commented Aug 20, 2019

@nijanthan0 I had this issue with elasticsearch installed via brew on mac Mojave and was able to resolve it with the following steps:

  1. Create a gc.log file in /usr/local/var/log/elasticsearch via touch gc.log (In the terminal, at that location)
  2. Edit elasticsearch jvm.options (for me located at /usr/etc/elasticsearch/jvm.options) to set the 8:-Xloggc flag to a full path
    Before: 8:-Xloggc:logs/gc.log
    After: 8:-Xloggc:/usr/local/var/log/elasticsearch/gc.log
  3. Restart elasticsearch via brew services restart elasticsearch

This is for elasticsearch 6.8.1 installed via homebrew with the following output from java -version

java -version                                                                                                     
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

@subhashb
Copy link

@vaelinn123 @nijanthan0
For Java versions 9 and beyond, the parameter to be changed is in the # JDK 9+ GC logging section in the same jvm.options file:

  • Before: 9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
  • After: 9-:-Xlog:gc*,gc+age=trace,safepoint:file=/usr/local/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m

@asis012
Copy link

asis012 commented Feb 12, 2020

make a gc.log life inside /usr/local/var/log/elasticsearch/ using touch gc.log
and
copy and rplace these two lines in jvm.options

8:-Xloggc:/usr/local/var/log/elasticsearch/gc.log

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

and restart services

@winadiw
Copy link

winadiw commented Feb 20, 2020

for me, there was an error, because previusly using Homebrew, i install version 6.8.3.
After that i decided to upgrade to version 7.x, so i remove 6.8.3 and install latest (7.6.0). Then this error shows up when i run elasticsearch

To solve, i uninstall 7.6.0 first, then remove /usr/local/etc/elasticsearch, install 7.6.0 again.

Credit:
https://discuss.elastic.co/t/elasticsearch-7-2-0-homebrew-install-on-mac-java-error-on-startup-fail/192760/4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests