Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to restart elasticsearch

I have elasticsearch version 2.3.3 installed on a vm with ubuntu version 14.04. I have tried to restart the elasticsearch service but after the restart I checked the status with sudo service elasticsearch status and it returned * elasticsearch is not running. When I try to start it using sudo service elasticsearch start it returns * Starting Elasticsearch Server but checking the status it turns out to be not running.

I have tried to manually start it by entering /usr/share/elasticsearch/bin/elasticsearch (which is the path of the binary file) but at the beginning I was getting the following error:

Exception in thread "main" ElasticsearchException[Failed to load logging configuration]; nested: NoSuchFileException[/usr/share/elasticsearch/config];
Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
    at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
    at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:97)
    at java.nio.file.Files.readAttributes(Files.java:1686)
    at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:109)
    at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:69)
    at java.nio.file.Files.walkFileTree(Files.java:2602)
    at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:142)
    at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:103)
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

The error tells it is not able to find the logging configuration so I followed the advice in https://github.com/elastic/ansible-elasticsearch/issues/58 by creating a symbolic link: sudo ln -s /etc/elasticsearch/ /usr/share/elasticsearch/config

Afterwards I'm getting the following error when running elastic search through /usr/share/elasticsearch/bin/elasticsearch:

Exception in thread "main" ElasticsearchException[Failed to load logging configuration]; nested: AccessDeniedException[/usr/share/elasticsearch/config];
Likely root cause: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/config
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:426)
    at java.nio.file.Files.newDirectoryStream(Files.java:413)
    at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:179)
    at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:69)
    at java.nio.file.Files.walkFileTree(Files.java:2602)
    at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:142)
    at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:103)
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

When trying as root (sudo /usr/share/elasticsearch/bin/elasticsearch) I get the following error:

Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

This is not the first time I face this issue. I faced exactly the same problem (with the first exception - logging config not found) on another virtual machine and tried to solve it by creating the path /usr/share/elasticsearch/config and copying the config files (elasticsearch.yml and logging.yml) to it. Afterwards I faced the second problem again (running as normal user - access denied and running as root is not allowed).

Does anybody have an idea about this problem? Any help will be appretiated!

like image 884
mshabeeb Avatar asked Dec 02 '25 17:12

mshabeeb


2 Answers

In my case the following link helped :

ln -s /etc/elasticsearch/ /usr/share/elasticsearch/config
like image 171
Steve Lng C Avatar answered Dec 04 '25 10:12

Steve Lng C


Have you tried to do the following:

1) Create the directories

$ mkdir -p /usr/share/elasticsearch/config/scripts

2) Copying over log and config files

$ cp /etc/elasticsearch/elasticsearch.yml /user/share/elasticshare/config
$ cp /etc/elasticsearch/logging.yml /user/share/elasticshare/config

3) Change permissions or change ownership on these files.

$ sudo chmod g+rwx /usr/share/elasticsearch/config/elasticsearch.yml /usr/share/elasticsearch/config/logging.yml 
$ sudo chmod o+rwx /usr/share/elasticsearch/config/elasticsearch.yml /usr/share/elasticsearch/config/logging.yml
like image 25
Rakesh Rakshit Avatar answered Dec 04 '25 10:12

Rakesh Rakshit