I installed Eleasticsearch following the tutorial: Install Elasticsearch with Debian Package | Elasticsearch Guide [8.3] | Elastic
Everything installs perfectly:
Unpacking elasticsearch (8.3.2) ...
Setting up elasticsearch (8.3.2) ...
--------------------------- Security autoconfiguration information ------------------------------
Skipping auto-configuration because security features appear to be already configured.
-------------------------------------------------------------------------------------------------
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
sudo systemctl start elasticsearch.service
Created elasticsearch keystore in /etc/elasticsearch/elasticsearch.keystor
Step 1:
marius@marius:~$ sudo systemctl daemon-reload
marius@marius:~$ sudo systemctl enable elasticsearch.service
Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service β /lib/systemd/system/elasticsearch.service.
marius@marius:~$ sudo systemctl start elasticsearch.service
Job for elasticsearch.service failed because the control process exited with error code.
See "systemctl status elasticsearch.service" and "journalctl -xe" for details.
Step 2:
marius@marius:~$ systemctl status elasticsearch.service
Result:
β elasticsearch.service - Elasticsearch
Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2022-07-14 07:55:08 EEST; 16s ago
Docs: https://www.elastic.co
Process: 6862 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1/FAILURE)
Main PID: 6862 (code=exited, status=1/FAILURE)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.xpack.security.cli.AutoConfigureNode.execute(AutoConfigureNode.java:166)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.server.cli.ServerCli.autoConfigureSecurity(ServerCli.java:149)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.server.cli.ServerCli.execute(ServerCli.java:87)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:54)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.cli.Command.main(Command.java:50)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.launcher.CliToolLauncher.main(CliToolLauncher.java:64)
Jul 14 07:55:08 marius systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Jul 14 07:55:08 marius systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
Jul 14 07:55:08 marius systemd[1]: Failed to start Elasticsearch.
Step 3:
marius@marius:~$ journalctl -u elasticsearch.service
Result:
-- Logs begin at Thu 2022-07-14 07:42:08 EEST, end at Thu 2022-07-14 07:58:19 EEST. --
Jul 14 07:55:07 marius systemd[1]: Starting Elasticsearch...
Jul 14 07:55:08 marius systemd-entrypoint[6862]: Exception in thread "main" java.nio.file.AccessDeniedException: /var/lib/elasticsearch
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at java.base/sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:440)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at java.base/java.nio.file.Files.newDirectoryStream(Files.java:482)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at java.base/java.nio.file.Files.list(Files.java:3793)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.xpack.security.cli.AutoConfigureNode.isDirEmpty(AutoConfigureNode.java:1144)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.xpack.security.cli.AutoConfigureNode.execute(AutoConfigureNode.java:166)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.server.cli.ServerCli.autoConfigureSecurity(ServerCli.java:149)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.server.cli.ServerCli.execute(ServerCli.java:87)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:54)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:85)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.cli.Command.main(Command.java:50)
Jul 14 07:55:08 marius systemd-entrypoint[6862]: at org.elasticsearch.launcher.CliToolLauncher.main(CliToolLauncher.java:64)
Jul 14 07:55:08 marius systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Jul 14 07:55:08 marius systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
Jul 14 07:55:08 marius systemd[1]: Failed to start Elasticsearch.
Step 4:
I've changed permisions in different ways to first to elesticsearch after to user "marius", so not root but the elasticsearch service do not start.
marius@marius:/etc$ sudo chmod +x elasticsearch
marius@marius:/etc$ sudo ls -l elasticsearch
total 48
-rw-rw---- 1 root elasticsearch 199 Jul 14 07:53 elasticsearch.keystore
-rw-rw---- 1 root elasticsearch 1042 Jul 6 18:22 elasticsearch-plugins.example.yml
-rw-rw---- 1 root elasticsearch 2919 Jul 6 18:22 elasticsearch.yml
-rw-rw---- 1 root elasticsearch 2617 Jul 6 18:22 jvm.options
drwxr-s--- 2 root elasticsearch 4096 Jul 6 18:22 jvm.options.d
-rw-rw---- 1 root elasticsearch 16644 Jul 6 18:22 log4j2.properties
-rw-rw---- 1 root elasticsearch 473 Jul 6 18:22 role_mapping.yml
-rw-rw---- 1 root elasticsearch 197 Jul 6 18:22 roles.yml
-rw-rw---- 1 root elasticsearch 0 Jul 6 18:22 users
-rw-rw---- 1 root elasticsearch 0 Jul 6 18:22 users_roles
marius@marius:/etc$ sudo chown -R elasticsearch:elasticsearch elasticsearch
marius@marius:/etc$ sudo ls -l elasticsearch
total 48
-rw-rw---- 1 elasticsearch elasticsearch 199 Jul 14 07:53 elasticsearch.keystore
-rw-rw---- 1 elasticsearch elasticsearch 1042 Jul 6 18:22 elasticsearch-plugins.example.yml
-rw-rw---- 1 elasticsearch elasticsearch 2919 Jul 6 18:22 elasticsearch.yml
-rw-rw---- 1 elasticsearch elasticsearch 2617 Jul 6 18:22 jvm.options
drwxr-s--- 2 elasticsearch elasticsearch 4096 Jul 6 18:22 jvm.options.d
-rw-rw---- 1 elasticsearch elasticsearch 16644 Jul 6 18:22 log4j2.properties
-rw-rw---- 1 elasticsearch elasticsearch 473 Jul 6 18:22 role_mapping.yml
-rw-rw---- 1 elasticsearch elasticsearch 197 Jul 6 18:22 roles.yml
-rw-rw---- 1 elasticsearch elasticsearch 0 Jul 6 18:22 users
-rw-rw---- 1 elasticsearch elasticsearch 0 Jul 6 18:22 users_roles
marius@marius:/etc$ sudo chown -R marius:marius elasticsearch
marius@marius:/etc$ sudo ls -l elasticsearch
total 48
-rw-rw---- 1 marius marius 199 Jul 14 07:53 elasticsearch.keystore
-rw-rw---- 1 marius marius 1042 Jul 6 18:22 elasticsearch-plugins.example.yml
-rw-rw---- 1 marius marius 2919 Jul 6 18:22 elasticsearch.yml
-rw-rw---- 1 marius marius 2617 Jul 6 18:22 jvm.options
drwxr-s--- 2 marius marius 4096 Jul 6 18:22 jvm.options.d
-rw-rw---- 1 marius marius 16644 Jul 6 18:22 log4j2.properties
-rw-rw---- 1 marius marius 473 Jul 6 18:22 role_mapping.yml
-rw-rw---- 1 marius marius 197 Jul 6 18:22 roles.yml
-rw-rw---- 1 marius marius 0 Jul 6 18:22 users
-rw-rw---- 1 marius marius 0 Jul 6 18:22 users_roles
Step 5:
I try to see full logs but no logs. Also I discovered that almost everything related to Elasticsearch is Permission denied for user:
marius@marius:~$ cd /var/log/elasticsearch
bash: cd: /var/log/elasticsearch: Permission denied
marius@marius:~$ sudo bash
[sudo] password for marius:
root@marius:/home/marius# cd /var/log/elasticsearch
root@marius:/var/log/elasticsearch# ls
root@marius:/var/log/elasticsearch# ls -la
total 8
drwxr-s--- 2 elasticsearch elasticsearch 4096 Jul 6 18:22 .
drwxrwxr-x 11 root syslog 4096 Jul 14 07:53 ..
Elasticsearch works fine on Linux Mint 20.3 if installed from the archive option, I tested this. But I need to install via the deb package to be able to automatically start the service on boot, symlink is not possible if installed via the archive option for autostart on boot.
Question: Does anyone have any clue how to start Eleasticsearch if it is installed via .deb package?