0

As the title says, I have deleted /var/lib/elasticsearch and since then the service refuses to restart

Here's the log:

[2020-11-07T01:29:17,855][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [testNode] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: Unable to access 'path.data' (/var/lib/elasticsearch)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:174) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127) ~[elasticsearch-cli-7.9.2.jar:7.9.2]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.9.2.jar:7.9.2]
Caused by: java.lang.IllegalStateException: Unable to access 'path.data' (/var/lib/elasticsearch)
at org.elasticsearch.bootstrap.FilePermissionUtils.addDirectoryPath(FilePermissionUtils.java:70) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Security.addFilePermissions(Security.java:297) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Security.createPermissions(Security.java:252) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Security.configure(Security.java:121) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:222) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.9.2.jar:7.9.2]
... 6 more
Caused by: java.nio.file.AccessDeniedException: /var/lib/elasticsearch
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?]
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106) ~[?:?]
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]
at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:388) ~[?:?]
at java.nio.file.Files.createDirectory(Files.java:694) ~[?:?]
at java.nio.file.Files.createAndCheckIsDirectory(Files.java:801) ~[?:?]
at java.nio.file.Files.createDirectories(Files.java:787) ~[?:?]
at org.elasticsearch.bootstrap.Security.ensureDirectoryExists(Security.java:389) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.FilePermissionUtils.addDirectoryPath(FilePermissionUtils.java:68) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Security.addFilePermissions(Security.java:297) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Security.createPermissions(Security.java:252) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Security.configure(Security.java:121) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:222) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393) ~[elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.9.2.jar:7.9.2]

It says Unable to access 'path.data' (/var/lib/elasticsearch) but that's because it doesn't exist anymore.

Any idea? Elasticsearch is so frustrating and finding answers is even more.

Dastan
  • 176
  • 3
  • 15
  • 2
    Why did you delete it? The `path.data` is where elasticsearch will store the data about your index, nodes and cluster. The error is pretty clear, you need to recreate the directory or change the `path.data` in the `elasticsearch.yml` file. – leandrojmp Nov 07 '20 at 04:18
  • I don't know man, I guessed elastic would do it itself as it did the first time. I guess im not used to linux yet. Thanks – Dastan Nov 07 '20 at 12:42

1 Answers1

3

you must recreate the path with elasticsearch user permission.

mkdir -p /var/lib/elasticsearch
chown -R elasticsearch:elasticsearch /var/lib/elasticsearch

if you have permission problem again try:

chmod -R 755 /var/lib/elasticsearch
hamid bayat
  • 2,029
  • 11
  • 20