简体   繁体   中英

Can not run Elastic Search on ubuntu (Error opening log file)

I have problems with running Elastic Search on my ubuntu 20.04 server (I can do it locally). When I run ./bin/elasticsearch in terminal I get lines below

Exception in thread "main" java.lang.RuntimeException: starting java failed with [1]
output:
[0.000s][error][logging] Error opening log file 'logs/gc.log': Permission denied
[0.001s][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.
Could not rename log file 'logs/gc.log' to 'logs/gc.log.05' (Permission denied).
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.JvmOption.flagsFinal(JvmOption.java:119)
    at org.elasticsearch.tools.launchers.JvmOption.findFinalOptions(JvmOption.java:81)
    at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:38)
    at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:135)
    at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:86)

What I tried: sudo chmod -R +w /home/ubuntu/data/stepa/elasticsearch-7.16.2/logs/ . It didn't help. I didn't succeed to find answer on elastic search forum. Thank you for any help.

Finally, I found the solution. Log lines mean problems with rights. Current user has to be an owner of directory. In my case owner of /home/ubuntu/data/stepa/elasticsearch-7.16.2/logs/ was root. I changed it using this command sudo chown username:group /home/ubuntu/data/stepa/elasticsearch-7.16.2/logs ("ubuntu: " in my case because group is default and username is ubuntu)

Thanks to ilvar for clues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM