Magento2: Elasticsearch failed to start: problem with java

Hello,
I've installed Magento2.4.4 in ubuntu20.04 VM. When i did the installation everything was fine.
Now I am facing a failure . I tried almost everything to fix it, but nothing. Here is the output:

Also in the Elasticsearch.yml file I changed only the network host: 127.0.0.1.
In the jvm.options file:
image_2022-06-03_130608414
image_2022-06-03_130625918


I have java version:11 end elaasticsearch version is: 7
I do not know what else to do. Any suggestion?

@Konstantina_Gerou Welcome to the community.

Can you share the full stack trace from es log file . It's not clear and incomplete trace to figure out the actual cause .

1 Like

Do you mean this?

Yes , if possible copy paste the full content of the file , rather than attaching screen shot.

● Elasticsearch.service - Elasticsearch
Loaded: loaded (/lib/systemd/system/Elasticsearch.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2022-06-03 12:07:11 UTC; 1h 22min ago
Docs: https://www.elastic.co
Main PID: 37068 (code=exited, status=1/FAILURE)

Jun 03 12:07:11 backup-71745322-ubuntu-4gb-hel1-1 systemd-entrypoint[37221]: at java.base/java.nio.file.Files.newByteChannel(Files.java:380)
Jun 03 12:07:11 backup-71745322-ubuntu-4gb-hel1-1 systemd-entrypoint[37221]: at java.base/java.nio.file.Files.newByteChannel(Files.java:432)
Jun 03 12:07:11 backup-71745322-ubuntu-4gb-hel1-1 systemd-entrypoint[37221]: at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:422)
Jun 03 12:07:11 backup-71745322-ubuntu-4gb-hel1-1 systemd-entrypoint[37221]: at java.base/java.nio.file.Files.newInputStream(Files.java:160)
Jun 03 12:07:11 backup-71745322-ubuntu-4gb-hel1-1 systemd-entrypoint[37221]: at org.Elasticsearch.tools.launchers.JvmOptionsParser.readJvmOptionsFiles(JvmOptionsParser.java:168)
Jun 03 12:07:11 backup-71745322-ubuntu-4gb-hel1-1 systemd-entrypoint[37221]: at org.Elasticsearch.tools.launchers.JvmOptionsParser.jvmOptions(JvmOptionsParser.java:124)
Jun 03 12:07:11 backup-71745322-ubuntu-4gb-hel1-1 systemd-entrypoint[37221]: at org.Elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:86)
Jun 03 12:07:11 backup-71745322-ubuntu-4gb-hel1-1 systemd[1]: Elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Jun 03 12:07:11 backup-71745322-ubuntu-4gb-hel1-1 systemd[1]: Elasticsearch.service: Failed with result 'exit-code'.
Jun 03 12:07:11 backup-71745322-ubuntu-4gb-hel1-1 systemd[1]: Failed to start Elasticsearch.
~
Here it is

And here is a more clear screenshot

What's the http.port value in your Elasticsearch yaml file ?

Kindly share the Elasticsearch yaml file content as well.

Also please check below thread once :

Unfortunatelly, it did not helped me.
This is the Elasticsearch.yml file.

======================== Elasticsearch Configuration =========================

NOTE: Elasticsearch comes with reasonable defaults for most settings.

Before you set out to tweak and tune the configuration, make sure you

understand what are you trying to accomplish and the consequences.

The primary way of configuring a node is via this file. This template lists

the most important settings you may want to configure for a production cluster.

Please consult the documentation for further information on configuration options:

Elasticsearch Guide | Elastic

---------------------------------- Cluster -----------------------------------

Use a descriptive name for your cluster:

#cluster.name: my-application

------------------------------------ Node ------------------------------------

Use a descriptive name for the node:

#node.name: node-1

Add custom attributes to the node:

#node.attr.rack: r1

----------------------------------- Paths ------------------------------------

Path to directory where to store the data (separate multiple locations by comma):

path.data: /var/lib/Elasticsearch

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:
#ompressed class space mapped at: 0x0000000100000000-0x0000000140000000, reserved size: 1073741824
#[2022-05-31T13:45:21.243+0000][47882][gc,metaspace] Narrow klass base: 0x0000000000000000, Narrow klass shift: 3, Narrow klas range 0x140000000
#[2022-05-31T13:45:21.315+0000][47882][gc,heap,exit] Heap
#[2022-05-31T13:45:21.315+0000][47882][gc,heap,exit] garbage-first heap total 1964032K, used 1538K [0x0000000088200000, 0x0000000100000000)
#[2022-05-31T13:45:21.315+0000][47882][gc,heap,exit] region size 1024K, 2 young (2048K), 0 survivors (OK)
#[2022-05-31T13:45:21.315+0000][47882][gc,heap,exit] Metaspace used 3474K, committed 3584K, reserved 1114112K
#[2022-05-31T13:45:21.315+0000][47882][gc,heap,exit] class space used 263K, committed 320K, reserved 1048576K
#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

---------------------------------- Security ----------------------------------

*** WARNING ***

Elasticsearch security features are not enabled by default.

These features are free, but require configuration changes to enable them.

This means that users don’t have to provide credentials and can get full access

to the cluster. Network connections are also not encrypted.

To protect your data, we strongly encourage you to enable the Elasticsearch security features.

Refer to the following documentation for instructions.

Configure security for the Elastic Stack | Elasticsearch Guide [7.16] | Elastic

And here is the jvm.options file.
################################################################

JVM configuration

################################################################

WARNING: DO NOT EDIT THIS FILE. If you want to override the

JVM options in this file, or set any additional options, you

should create one or more files in the jvm.options.d

directory containing your adjustments.

See Setting JVM options | Elasticsearch Guide [7.17] | Elastic

for more information.

################################################################

################################################################

IMPORTANT: JVM heap size

################################################################

The heap size is automatically configured by Elasticsearch

based on the available memory in your system and the roles

each node is configured to fulfill. If specifying heap is

required, it should be done through a file in jvm.options.d,

and the min and max should be set to the same value. For

example, to set the heap to 4 GB, create a new file in the

jvm.options.d directory containing these lines:

-Xms512m
-Xmx512m

See Heap size settings | Elasticsearch Guide [7.17] | Elastic

for more infionsP

################################################################

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

exit right after heap dump on out of memory error. Recommended to also use

on java 8 for supported versions (8u92+).

9-:-XX:+ExitOnOutOfMemoryError

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

9-:-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/Elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m

I solved it. I just did: chown -R Elasticsearch:Elasticsearch /etc/Elasticsearch

Good to know @Konstantina_Gerou :slight_smile:

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