How to run elasticsearch when installed from source?

Hi, so I want to install Elasticsearch from archieve (Install Elasticsearch from archive on Linux or MacOS | Elasticsearch Guide [7.15] | Elastic). Why? Because I need to install them on custom path (by default Elasticsearch installed on /etc/Elasticsearch).

From the documentation,it is said that I just need to run this to start the service:

./bin/elasticsearch -d -p pid

But, I won't start on reboot, right? So, I create systemd service using reference from systemd service when we install from package.

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

[Service]
Type=notify
RuntimeDirectory=elasticsearch-7.15.0
PrivateTmp=true
Environment=ES_HOME=/mnt/elasticsearch-7.15.0
Environment=ES_PATH_CONF=/mnt/elasticsearch-7.15.0/
Environment=PID_DIR=/mnt/elasticsearch-7.15.0/var/run
Environment=ES_SD_NOTIFY=true

WorkingDirectory=/mnt/elasticsearch-7.15.0

User=deployer
Group=deployer

ExecStart=/mnt/elasticsearch-7.15.0/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet

And create systemd-entrypoint script:

#!/bin/sh

# This wrapper script allows SystemD to feed a file containing a passphrase into
# the main Elasticsearch startup script

if [ -n "$ES_KEYSTORE_PASSPHRASE_FILE" ] ; then
  exec /mnt/elasticsearch-7.15.0/bin/elasticsearch "$@" < "$ES_KEYSTORE_PASSPHRASE_FILE"
else
  exec /mnt/elasticsearch-7.15.0/bin/elasticsearch "$@"
fi

But, when I run systemctl start Elasticsearch it won't start and get error:

elasticsearch.service: Main process exited, code=exited, status=203/EXEC

Why that error mean? Or maybe any other idea? My goal is just to make sure my Elasticsearch service will run automatically after server reboot.

What do the Elasticsearch logs say?

The issue on my post has resolved after I modify my ExecStart to:

ExecStart=/bin/bash /mnt/elasticsearch-7.15.0/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet

But I got another error:

-- Unit elasticsearch.service has begun starting up.
Sep 24 12:50:36 ag-rh1 bash[161367]: Exception in thread "main" java.nio.file.NoSuchFileException: /mnt/elasticsearch-7.15.0/jvm.options
Sep 24 12:50:36 ag-rh1 bash[161367]:         at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
Sep 24 12:50:36 ag-rh1 bash[161367]:         at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
Sep 24 12:50:36 ag-rh1 bash[161367]:         at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
Sep 24 12:50:36 ag-rh1 bash[161367]:         at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
Sep 24 12:50:36 ag-rh1 bash[161367]:         at java.base/java.nio.file.Files.newByteChannel(Files.java:375)
Sep 24 12:50:36 ag-rh1 bash[161367]:         at java.base/java.nio.file.Files.newByteChannel(Files.java:426)
Sep 24 12:50:36 ag-rh1 bash[161367]:         at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
Sep 24 12:50:36 ag-rh1 bash[161367]:         at java.base/java.nio.file.Files.newInputStream(Files.java:160)
Sep 24 12:50:36 ag-rh1 bash[161367]:         at org.elasticsearch.tools.launchers.JvmOptionsParser.readJvmOptionsFiles(JvmOptionsParser.java:168)
Sep 24 12:50:36 ag-rh1 bash[161367]:         at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:124)
Sep 24 12:50:36 ag-rh1 bash[161367]:         at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:86)
Sep 24 12:50:36 ag-rh1 systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Sep 24 12:50:36 ag-rh1 systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support

Elasticsearch.log:

[2021-09-24T12:29:28,876][INFO ][o.e.n.Node               ] [ag-rh1] initialized
[2021-09-24T12:29:28,877][INFO ][o.e.n.Node               ] [ag-rh1] starting ...
[2021-09-24T12:29:28,954][INFO ][o.e.x.s.c.f.PersistentCache] [ag-rh1] persistent cache index loaded
[2021-09-24T12:29:29,305][INFO ][o.e.t.TransportService   ] [ag-rh1] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2021-09-24T12:29:30,200][WARN ][o.e.b.BootstrapChecks    ] [ag-rh1] the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
[2021-09-24T12:29:30,203][INFO ][o.e.c.c.Coordinator      ] [ag-rh1] cluster UUID [8RiH8uunTJSOiu12370y0Q]
[2021-09-24T12:29:30,230][INFO ][o.e.c.c.ClusterBootstrapService] [ag-rh1] no discovery configuration found, will perform best-effort cluster bootstrapping after [3s] unless existing master is discovered
[2021-09-24T12:29:30,538][INFO ][o.e.c.s.MasterService    ] [ag-rh1] elected-as-master ([1] nodes joined)[{ag-rh1}{ru_p1kc-QRykkphr6vhhKA}{-AI_55TVRZSDamRkYsoM1A}{127.0.0.1}{127.0.0.1:9300}{cdfhilmrstw} elect leader, _BECOME_MASTER_TASK_, _FINISH_ELECTION_], term: 2, version: 47, delta: master node changed {previous [], current [{ag-rh1}{ru_p1kc-QRykkphr6vhhKA}{-AI_55TVRZSDamRkYsoM1A}{127.0.0.1}{127.0.0.1:9300}{cdfhilmrstw}]}
[2021-09-24T12:29:30,883][INFO ][o.e.c.s.ClusterApplierService] [ag-rh1] master node changed {previous [], current [{ag-rh1}{ru_p1kc-QRykkphr6vhhKA}{-AI_55TVRZSDamRkYsoM1A}{127.0.0.1}{127.0.0.1:9300}{cdfhilmrstw}]}, term: 2, version: 47, reason: Publication{term=2, version=47}
[2021-09-24T12:29:31,295][INFO ][o.e.h.AbstractHttpServerTransport] [ag-rh1] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2021-09-24T12:29:31,296][INFO ][o.e.n.Node               ] [ag-rh1] started
[2021-09-24T12:29:32,354][INFO ][o.e.l.LicenseService     ] [ag-rh1] license [a0a29a4d-0021-4989-8a18-0ff52c181645] mode [basic] - valid
[2021-09-24T12:29:32,357][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [ag-rh1] Active license is now [BASIC]; Security is disabled
[2021-09-24T12:29:32,358][WARN ][o.e.x.s.s.SecurityStatusChangeListener] [ag-rh1] Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone. See https://www.elastic.co/guide/en/elasticsearch/reference/7.15/security-minimal-setup.html to enable security.
[2021-09-24T12:29:32,383][INFO ][o.e.g.GatewayService     ] [ag-rh1] recovered [1] indices into cluster_state
[2021-09-24T12:29:33,688][INFO ][o.e.i.g.GeoIpDownloader  ] [ag-rh1] updating geoip databases
[2021-09-24T12:29:33,690][INFO ][o.e.i.g.GeoIpDownloader  ] [ag-rh1] fetching geoip databases overview from [https://geoip.elastic.co/v1/database?elastic_geoip_service_tos=agree]
[2021-09-24T12:29:34,193][INFO ][o.e.c.r.a.AllocationService] [ag-rh1] Cluster health status changed from [RED] to [GREEN] (reason: [shards started [[.geoip_databases][0]]]).
[2021-09-24T12:29:34,565][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] downloading geoip database [GeoLite2-Country.mmdb] to [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-Country.mmdb.tmp.gz]
[2021-09-24T12:29:34,567][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] downloading geoip database [GeoLite2-ASN.mmdb] to [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-ASN.mmdb.tmp.gz]
[2021-09-24T12:29:34,567][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] downloading geoip database [GeoLite2-City.mmdb] to [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-City.mmdb.tmp.gz]
[2021-09-24T12:29:34,906][INFO ][o.e.i.g.GeoIpDownloader  ] [ag-rh1] updating geoip database [GeoLite2-ASN.mmdb]
[2021-09-24T12:29:35,912][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] successfully reloaded changed geoip database file [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-Country.mmdb]
[2021-09-24T12:29:35,920][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] successfully reloaded changed geoip database file [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-ASN.mmdb]
[2021-09-24T12:29:39,514][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] successfully reloaded changed geoip database file [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-City.mmdb]
[2021-09-24T12:29:40,213][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] downloading geoip database [GeoLite2-ASN.mmdb] to [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-ASN.mmdb.tmp.gz]
[2021-09-24T12:29:40,331][INFO ][o.e.i.g.GeoIpDownloader  ] [ag-rh1] updated geoip database [GeoLite2-ASN.mmdb]
[2021-09-24T12:29:40,387][INFO ][o.e.i.g.GeoIpDownloader  ] [ag-rh1] updating geoip database [GeoLite2-City.mmdb]
[2021-09-24T12:29:40,679][INFO ][o.e.i.g.DatabaseReaderLazyLoader] [ag-rh1] evicted [0] entries from cache after reloading database [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-ASN.mmdb]
[2021-09-24T12:29:40,680][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] successfully reloaded changed geoip database file [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-ASN.mmdb]
[2021-09-24T12:29:47,703][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] downloading geoip database [GeoLite2-City.mmdb] to [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-City.mmdb.tmp.gz]
[2021-09-24T12:29:47,778][INFO ][o.e.i.g.GeoIpDownloader  ] [ag-rh1] updated geoip database [GeoLite2-City.mmdb]
[2021-09-24T12:29:47,780][INFO ][o.e.i.g.GeoIpDownloader  ] [ag-rh1] updating geoip database [GeoLite2-Country.mmdb]
[2021-09-24T12:29:49,667][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] downloading geoip database [GeoLite2-Country.mmdb] to [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-Country.mmdb.tmp.gz]
[2021-09-24T12:29:49,723][INFO ][o.e.i.g.GeoIpDownloader  ] [ag-rh1] updated geoip database [GeoLite2-Country.mmdb]
[2021-09-24T12:29:50,012][INFO ][o.e.i.g.DatabaseReaderLazyLoader] [ag-rh1] evicted [0] entries from cache after reloading database [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-Country.mmdb]
[2021-09-24T12:29:50,013][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] successfully reloaded changed geoip database file [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-Country.mmdb]
[2021-09-24T12:29:51,207][INFO ][o.e.i.g.DatabaseReaderLazyLoader] [ag-rh1] evicted [0] entries from cache after reloading database [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-City.mmdb]
[2021-09-24T12:29:51,207][INFO ][o.e.i.g.DatabaseRegistry ] [ag-rh1] successfully reloaded changed geoip database file [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-City.mmdb]
[2021-09-24T12:49:31,827][INFO ][o.e.n.Node               ] [ag-rh1] stopping ...
[2021-09-24T12:49:31,839][INFO ][o.e.x.w.WatcherService   ] [ag-rh1] stopping watch service, reason [shutdown initiated]
[2021-09-24T12:49:31,845][INFO ][o.e.x.w.WatcherLifeCycleService] [ag-rh1] watcher has stopped and shutdown
[2021-09-24T12:49:31,864][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [ag-rh1] [controller/161098] [Main.cc@174] ML controller exiting
[2021-09-24T12:49:31,869][INFO ][o.e.x.m.p.NativeController] [ag-rh1] Native controller process has stopped - no new native processes can be started
[2021-09-24T12:49:32,560][INFO ][o.e.n.Node               ] [ag-rh1] stopped
[2021-09-24T12:49:32,560][INFO ][o.e.n.Node               ] [ag-rh1] closing ...
[2021-09-24T12:49:32,618][INFO ][o.e.i.g.DatabaseReaderLazyLoader] [ag-rh1] evicted [0] entries from cache after reloading database [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-Country.mmdb]
[2021-09-24T12:49:32,618][INFO ][o.e.i.g.DatabaseReaderLazyLoader] [ag-rh1] evicted [0] entries from cache after reloading database [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-ASN.mmdb]
[2021-09-24T12:49:32,618][INFO ][o.e.i.g.DatabaseReaderLazyLoader] [ag-rh1] evicted [0] entries from cache after reloading database [/tmp/elasticsearch-9100062167901577091/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-City.mmdb]
[2021-09-24T12:49:32,620][INFO ][o.e.n.Node               ] [ag-rh1] closed

FYI, It run normally if i run using ./bin/elasticsearch -d -p pid

This error also fixed after modify my config path to the right path.
But, it still error:

-- Unit elasticsearch.service has begun starting up.
Sep 24 14:05:45 ag-rh1 systemd[1]: elasticsearch.service: start operation timed out. Terminating.
Sep 24 14:05:46 ag-rh1 systemd[1]: elasticsearch.service: Failed with result 'timeout'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support

elasticsearch.log:

[2021-09-24T14:05:45,497][INFO ][o.e.x.w.WatcherService   ] [ag-rh1] stopping watch service, reason [shutdown initiated]
[2021-09-24T14:05:45,498][INFO ][o.e.x.w.WatcherLifeCycleService] [ag-rh1] watcher has stopped and shutdown
[2021-09-24T14:05:45,499][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [ag-rh1] [controller/163219] [Main.cc@174] ML controller exiting
[2021-09-24T14:05:45,500][INFO ][o.e.x.m.p.NativeController] [ag-rh1] Native controller process has stopped - no new native processes can be started
[2021-09-24T14:05:45,999][INFO ][o.e.n.Node               ] [ag-rh1] stopped
[2021-09-24T14:05:45,999][INFO ][o.e.n.Node               ] [ag-rh1] closing ...
[2021-09-24T14:05:46,013][INFO ][o.e.i.g.DatabaseReaderLazyLoader] [ag-rh1] evicted [0] entries from cache after reloading database [/tmp/elasticsearch-6791418185939870539/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-Country.mmdb]
[2021-09-24T14:05:46,014][INFO ][o.e.i.g.DatabaseReaderLazyLoader] [ag-rh1] evicted [0] entries from cache after reloading database [/tmp/elasticsearch-6791418185939870539/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-ASN.mmdb]
[2021-09-24T14:05:46,014][INFO ][o.e.i.g.DatabaseReaderLazyLoader] [ag-rh1] evicted [0] entries from cache after reloading database [/tmp/elasticsearch-6791418185939870539/geoip-databases/ru_p1kc-QRykkphr6vhhKA/GeoLite2-City.mmdb]
[2021-09-24T14:05:46,015][INFO ][o.e.n.Node               ] [ag-rh1] closed

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