Failed to start elastic search

Good evening, all seems ok, I have installed java 11, etc...
But when I want to start the service I have somes errors...
I put you the commandes and answers in putty :

[root@ortie-bio ~]# 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@ortie-bio ~]#
[root@ortie-bio ~]# 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 Wed 2021-05-19 16:18:45 CEST; 3min 7s ago
     Docs: https://www.elastic.co
  Process: 79231 ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=1/FAILURE)
 Main PID: 79231 (code=exited, status=1/FAILURE)

May 19 16:18:45 ortie-bio systemd-entrypoint[79231]: Error: Could not create the Java Virtual Machine.
May 19 16:18:45 ortie-bio systemd-entrypoint[79231]: Error: A fatal exception has occurred. Program will exit.
May 19 16:18:45 ortie-bio systemd-entrypoint[79231]:         at org.elasticsearch.tools.launchers.JvmOption.flagsFinal(JvmOption.java:119)
May 19 16:18:45 ortie-bio systemd-entrypoint[79231]:         at org.elasticsearch.tools.launchers.JvmOption.findFinalOptions(JvmOption.java:81)
May 19 16:18:45 ortie-bio systemd-entrypoint[79231]:         at org.elasticsearch.tools.launchers.JvmErgonomics.choose(JvmErgonomics.java:38)
May 19 16:18:45 ortie-bio systemd-entrypoint[79231]:         at org.elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:135)
May 19 16:18:45 ortie-bio systemd-entrypoint[79231]:         at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:86)
May 19 16:18:45 ortie-bio systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
May 19 16:18:45 ortie-bio systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
May 19 16:18:45 ortie-bio systemd[1]: Failed to start Elasticsearch.
[root@ortie-bio ~]#

Any ideas?

Welcome to our community! :smiley:

Please don't post pictures of text, they are difficult to read, impossible to search and replicate (if it's code), and some people may not be even able to see them :slight_smile:

Ok, I have modify my post, is it ok for you?

1 Like

once i had also faced this issue . if you are using a linux machine pls check the owner for the elasticsearch data directory. it should be elasticsearch and not root

ok, is the data directory in var/lib ? if it is the case I have rabitmq as owner... is it normal?
drwxr-s---. 3 rabbitmq rabbitmq 19 May 14 00:46 elasticsearch
I give you some others directory in case :
usr/share : drwxr-xr-x. 7 elasticsearch elasticsearch 129 May 14 00:19 elasticsearch
etc/ : drwxr-s---. 3 elasticsearch elasticsearch 245 May 18 18:18 elasticsearch
etc/sysconfig : -rw-rw----. 1 elasticsearch elasticsearch 1676 Apr 20 23:04 elasticsearch
In other wise I just realised I did all install login in root... I did create a magento user before the installation of magento, perhaps I should try to re-install java and elasticsearch login with this user?

Yes it will be in the path /var/lib. You can check elasticsearch.yml file for finding the data directory.

What does your Elasticsearch show?

Good morning
I can't go in the elasticsearch.yml and start with magento login:

[magento@ortie-bio /]$ sudo cd/etc/elasticsearch
sudo: /etc/sudo.conf is owned by uid 990, should be 0
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
[magento@ortie-bio /]$ sudo vi /etc/elasticsearch/elasticsearch.yml
sudo: /etc/sudo.conf is owned by uid 990, should be 0
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
[magento@ortie-bio /]$[magento@ortie-bio /]$ sudo systemctl elasticsearch.service
sudo: /etc/sudo.conf is owned by uid 990, should be 0
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
[magento@ortie-bio /]$

But I can enter the directory and edit the file with root login :

            #
    http.port: 9200
    #
    # For more information, consult the network module documentation.
    #
    # --------------------------------- Discovery ----------------------------------
    #
    # Pass an initial list of hosts to perform discovery when this node is started:
    # The default list of hosts is ["127.0.0.1", "[::1]"]
    #
    #discovery.seed_hosts: ["host1", "host2"]
    #
    # Bootstrap the cluster using an initial set of master-eligible nodes:
    #
    #cluster.initial_master_nodes: ["node-1", "node-2"]
    #
    # For more information, consult the discovery and cluster formation module documentation.
    #
    # ---------------------------------- Various -----------------------------------
    #
    # Require explicit names when deleting indices:
    #
    #action.destructive_requires_name: true
    -- INSERT --

In root login for the start :

[root@ortie-bio /]# 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@ortie-bio /]#

You will always need root user privilege to edit yml files.

Please go through the below topic to fix your error

@cedler from the above stack overflow topic please take these two things into consideration to fix your issue.

  1. network settings

  2. owner of the directory

ok, Thanks you gokul6 to try to help me but I did tried all that and with the link you suggested too but always no starting...
For the rights :

drwxr-s---.  3 elasticsearch elasticsearch    245 May 20 23:55 elasticsearch

For the elasticsearch.yml :

# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: 127.0.0.1
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: []
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

For the options.jvm :

################################################################
## Expert settings
################################################################
##
## All settings below here are considered expert settings. Do
## not adjust them unless you understand what you are doing. Do
## not edit them in this file; instead, create a new file in the
## jvm.options.d directory containing your adjustments.
##
################################################################

## GC configuration
8-13:-XX:+UseConcMarkSweepGC
8-13:-XX:CMSInitiatingOccupancyFraction=75
8-13:-XX:+UseCMSInitiatingOccupancyOnly

## G1GC Configuration
# NOTE: G1 GC is only supported on JDK version 10 or later
# to use G1GC, uncomment the next two lines and update the version on the
# following three lines to your version of the JDK
# 10-13:-XX:-UseConcMarkSweepGC
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
14-:-XX:+UseG1GC

## JVM temporary directory
-Djava.io.tmpdir=${ES_TMPDIR}

## heap dumps

# generate a heap dump when an allocation from the Java heap fails; heap dumps
# are created in the working directory of the JVM unless an alternative path is
# specified
-XX:+HeapDumpOnOutOfMemoryError

# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=/var/lib/elasticsearch

# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log

## JDK 8 GC logging
8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:/var/log/elasticsearch/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m

# JDK 9+ GC logging
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:/var/log/elasticsearch/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m

# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m9-:-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m

Did you check that there is no problem with Java installation ?

Can you please write a simple Java program and execute it ?

Good evening,
I have all uninstalled (java+elasticsearch) and re-install, always the same... but in elasticsearch.yml I did put a distant ip adress whereas I installed it on my server... so I put a "#" at this line in comment and it works now...
Thnaks you

And what are the full logs when you uncomment?

Probably related to Bootstrap Checks | Elasticsearch Guide [7.12] | Elastic

Sorry, you want to see which file or command?

Elasticsearch logs.

Don't have time to search where is the logs files if you don't want to tell me... sorry ... here is the journalctl-xe if I put my adress ip :

-- Unit elasticsearch.service has finished shutting down.
May 22 19:18:43 ortie-bio systemd[1]: Starting Elasticsearch...
-- Subject: Unit elasticsearch.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit elasticsearch.service has begun starting up.
May 22 19:18:59 ortie-bio systemd-entrypoint[350178]: ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
May 22 19:18:59 ortie-bio systemd-entrypoint[350178]: bootstrap check failure [1] of [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.se>
May 22 19:18:59 ortie-bio systemd-entrypoint[350178]: ERROR: Elasticsearch did not exit normally - check the logs at /var/log/elasticsearch/cluster-ortie-bio.log
May 22 19:18:59 ortie-bio systemd[1]: elasticsearch.service: Main process exited, code=exited, status=78/CONFIG
May 22 19:18:59 ortie-bio systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- The unit elasticsearch.service has entered the 'failed' state with result 'exit-code'.
May 22 19:18:59 ortie-bio systemd[1]: Failed to start Elasticsearch.
-- Subject: Unit elasticsearch.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
--
-- Unit elasticsearch.service has failed.
--
-- The result is failed.
May 22 19:19:15 ortie-bio sshd[350417]: sshd_selinux_change_privsep_preauth_context: SELinux context file needs to be owned by root and not writable by anyone else [preauth]
May 22 19:19:15 ortie-bio sshd[350079]: Connection closed by invalid user default 202.80.219.16 port 3509 [preauth]
May 22 19:19:16 ortie-bio sshd[350417]: Invalid user fjc from 202.51.74.221 port 56319
May 22 19:19:16 ortie-bio sshd[350417]: pam_unix(sshd:auth): check pass; user unknown
May 22 19:19:16 ortie-bio sshd[350417]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=202.51.74.221
May 22 19:19:17 ortie-bio sshd[350417]: Failed password for invalid user fjc from 202.51.74.221 port 56319 ssh2
May 22 19:19:18 ortie-bio sshd[350417]: Received disconnect from 202.51.74.221 port 56319:11: Bye Bye [preauth]
May 22 19:19:18 ortie-bio sshd[350417]: Disconnected from invalid user fjc 202.51.74.221 port 56319 [preauth]

It depends on how you installed elasticsearch.

Here is an example in the docs: Install Elasticsearch with Debian Package | Elasticsearch Guide [7.12] | Elastic

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