How to Elasticsearch 5.5 as service RH Linux

Hello !

After some tests on preproduction with rpm, i begin to configure production environment.

Problem : Elasticsearch doesn't work in root user + It's not a service (source : tar.gz)

Currently context : Elasticsearch 5.5 with source .tar.gz

I want create a service for elasticsearch. So i have editer under " /etc/systemd/system/multi-user.target.wants/elasticsearch.service" :

[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target

[Service]
EnvironmentFile=-/etc/sysconfig/elasticsearch
WorkingDirectory=/opt/elasticsearch
User=elasticsearch
Group=elasticsearch
ExecStartPre=/opt/elasticsearch/bin/elasticsearch-systemd-pre-exec
ExecStart=/opt/elasticsearch/bin/elasticsearch \
                                        -p /var/run/elasticsearch/elasticsearch.pid \
                                        --quiet \
                                        -Edefault.path.logs=/opt/elasticsearch/logs \
                                        -Edefault.path.data=/elasticsearch-data \
                                        -Edefault.path.conf=/opt/elasticsearch/config

StandardError=inherit
LimitNOFILE=65536
LimitMEMLOCK=infinity
TimeoutStopSec=0
KillSignal=SIGTERM
SendSIGKILL=no
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

So when i start it, when i show service's status i see :

Active: failed (Result: exit-code) since Wed 2017-07-26 11:17:34 CEST; 17min ago
     Docs: http://www.elastic.co
  Process: 5177 ExecStart=/opt/elasticsearch/bin/elasticsearch -p /var/run/elasticsearch/elasticsearch.pid --quiet -Edefault.path.logs=/opt/elasticsearch/logs -Edefault.path.data=/elasticsearch-data -Edefault.path.conf=/opt/elasticsearch/config (code=exited, status=1/FAILURE)
  Process: 5174 ExecStartPre=/opt/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)
 Main PID: 5177 (code=exited, status=1/FAILURE)

Elasticsearch will never start as root user. You need to use another one.

You can also install Elasticsearch as using rpm which is available from the products section.

Please use rpm install commands so that Elasticsearch will be installed as a service. Only thing you have to do additional is to configure the systemctl to start the Elasticseach during boot.

1 Like

I have configure all binary ELK to service linux.

It's not important but, run soft with systemctl status/start/stop name_soft is More intuitive

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.