Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch crashes when updated data path

Elasticsearch setup works fine with default configurations. But when updated its path.data setting from elasticsearch.yml file it crashes with below error

[2015-11-19 12:39:56,194][ERROR][bootstrap                ] Exception
java.lang.IllegalStateException: Unable to access 'path.data' (/home/hadoop/bigdata/data/elasticsearch)
        at org.elasticsearch.bootstrap.Security.addPath(Security.java:197)
        at org.elasticsearch.bootstrap.Security.createPermissions(Security.java:170)
        at org.elasticsearch.bootstrap.Security.configure(Security.java:100)
        at org.elasticsearch.bootstrap.Bootstrap.setupSecurity(Bootstrap.java:181)
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:159)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Caused by: java.nio.file.AccessDeniedException: /home/hadoop/bigdata/data
        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.checkAccess(UnixFileSystemProvider.java:308)
        at java.nio.file.Files.createDirectories(Files.java:702)
        at org.elasticsearch.bootstrap.Security.ensureDirectoryExists(Security.java:218)
        at org.elasticsearch.bootstrap.Security.addPath(Security.java:195)
        ... 6 more

I have copied elasticsearch directory from /var/lib location with preserved mode. But no success. Can anybody please help me to come out of this error

Thanks, Sanjay Bhosale

like image 716
Sanjay Bhosale Avatar asked May 16 '26 20:05

Sanjay Bhosale


2 Answers

This error is coming because of not setting permissions for user "elasticsearch" to access the folder.

Try making "elasticsearch" user(default user of elasticsearch) the owner of the folder using below commands -

sudo chown elasticsearch: /home/hadoop/bigdata/data/elasticsearch
like image 159
Arijeet Saha Avatar answered May 19 '26 22:05

Arijeet Saha


In addition to ensure that the user elasticsearch is the owner and group of the data folder, the user should also have permission (+x) to traverse each level of the path to the configured data path (in your case, /home/hadoop/bigdata/data/elasticsearch).

That is, if the parent directory of the Elasticsearch path.data is not owned by user elasticsearch (as in your case, the parent folder belongs to user hadoop), then you should check each level of the parent directory, to ensure it be set with o+x permission (with chmod) to guarantee permission to the user elasticsearch (i.e., others).

I have learned this solution from other's question: Elasticsearch cannot open log file: Permission denied.

like image 37
Gary Wang Avatar answered May 19 '26 21:05

Gary Wang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!