Elasticsearch failed to start on CentOS 7

After installing elasticsearch on CentOS 7, it failed to start with error

[root@ns3160182 ~]# 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.
[root@ns3160182 ~]# 
[root@ns3160182 ~]# systemctl status elasticsearch.service
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2021-03-06 11:10:24 CET; 28s ago
     Docs: https://www.elastic.co
  Process: 10234 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1/FAILURE)
 Main PID: 10234 (code=exited, status=1/FAILURE)
   CGroup: /system.slice/elasticsearch.service

Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.cli.Command.main(Command.java:90)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd[1]: elasticsearch.service: main process exited, code=exited, status=1/FAILURE
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd[1]: Failed to start Elasticsearch.
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd[1]: Unit elasticsearch.service entered failed state.
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd[1]: elasticsearch.service failed.
[root@ns3160182 ~]#

On checking journalctl, i get

[root@ns3160182 ~]# journalctl -u elasticsearch
-- Logs begin at Sat 2021-02-13 16:48:02 CET, end at Sat 2021-03-06 11:12:02 CET. --
Mar 06 11:10:01 ns3160182.ip-151-106-34.eu systemd[1]: Starting Elasticsearch...
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: fatal error in thread [main], exiting
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.systemd.Libsystemd.lambda$static$0(Libsystemd.java:34)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.systemd.Libsystemd.(Libsystemd.java:33)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.systemd.SystemdPlugin.sd_notify(SystemdPlugin.java:126)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.systemd.SystemdPlugin.onNodeStarted(SystemdPlugin.java:137)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.node.Node.start(Node.java:902)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:317)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:402)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.cli.Command.main(Command.java:90)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd-entrypoint[10234]: at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd[1]: elasticsearch.service: main process exited, code=exited, status=1/FAILURE
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd[1]: Failed to start Elasticsearch.
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd[1]: Unit elasticsearch.service entered failed state.
Mar 06 11:10:24 ns3160182.ip-151-106-34.eu systemd[1]: elasticsearch.service failed.
[root@ns3160182 ~]# 

To fix this, edit file

vi /etc/sysconfig/elasticsearch

At end of the file, add

ES_TMPDIR=/var/log/elasticsearch

Now elasticsearch will start

systemctl start elasticsearch

elasticsearch CentOS 7 error

Verify service is running with

systemctl status elasticsearch

To confirm elasticsearch is running, use command

curl localhost:9200

See elasticsearch

Need help with Linux Server or WordPress? We can help!

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *