Elasticsearch: "ERROR: elasticsearch exited unexpectedly" when trying to start elasticsearch
Asked Answered
C

9

14

I am trying to start elasticsearch by running .bin/elasticsearch from the elasticsearch directory. However, I keep getting the error message ERROR: Elasticsearch exited unexpectedly. What could be the possible solution to this?

I installed Elasticsearch from archives on linux using the commands below.

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.3.3-linux-x86_64.tar.gz

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.3.3-linux-x86_64.tar.gz.sha512

shasum -a 512 -c elasticsearch-8.3.3-linux-x86_64.tar.gz.sha512 

tar -xzf elasticsearch-8.3.3-linux-x86_64.tar.gz

cd elasticsearch-8.3.3/ 
Caliber answered 10/8, 2022 at 14:5 Comment(5)
Could you share more about the error logs ?Matrass
Hello. I added more error logs to the questionCaliber
can not run elasticsearch as root are you using a root user ?Matrass
I saw that error. I was trying to run elasticsearch as root, so I had to exit root but the problem persisted.Caliber
removed error logs, as you're saying running as root was not the issueDissimilarity
J
13

I had this problem with docker (ElasticSearch version 8.6.2, docker engine 23.0.1, and Ubuntu 22.04), following the instructions in ElasticSearch docs:

https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-cli-run-dev-mode

Using ElasticSearch in single node mode for testing.

I solved it by setting the maximum amount of memory docker can use to 4GB (-m 4GB):

docker run --name es01 -m 4GB -p 9200:9200 -it docker.elastic.co/elasticsearch/elasticsearch:8.6.2
Janettejaneva answered 10/3, 2023 at 21:6 Comment(0)
H
9

You can solve this issue by increasing max_map_count to below or similar.

sudo sysctl -w vm.max_map_count=262144

My pain was immediately gone after running that command.

Huffman answered 17/5, 2023 at 13:8 Comment(0)
M
9

Adding -e "discovery.type=single-node" solved the issue for me on Docker:

docker run --name es-node01 --net elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -t docker.elastic.co/elasticsearch/elasticsearch:8.8.2
Marable answered 25/7, 2023 at 11:19 Comment(2)
For me following command helped to solve it docker run --name es-node01 --net elastic -e "discovery.type=single-node" -p 9200:9200 -p 9300:9300 -t docker.elastic.co/elasticsearch/elasticsearch:8.9.0Lampkin
That is the way it works on macOSSafranine
C
5

I've had this issue when running Elasticsearch as a container in Docker. Allowing Docker to reserve more resources fixed it for me. I've played around and in my setup a minimum of 6 GB RAM was needed in order to have a stable single node cluster of Elasticsearch running.

Collate answered 22/12, 2022 at 14:11 Comment(1)
Hence this step that I missed in the installation guide: “Install and start Docker Desktop. Go to Preferences > Resources > Advanced and set Memory to at least 4GB.”Hixson
N
5

Set the custom memory allocation as you want.

example with 512m (if you want to increase with 2GB, like this ES_JAVA_OPTS=-Xms2g -Xmx2g)

Docker Compose

version: "3"
services:
  elasticsearch:
    container_name: elasticsearch_springboot
    environment:
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"

Docker

docker run -d -p 9200:9200 -p 9300:9300 -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" --name elasticsearch docker.elastic.co/elasticsearch/elasticsearch:7.13.4

The ES_JAVA_OPTS environment variable in your Elasticsearch Docker Compose file is used to set the Java Virtual Machine (JVM) options for Elasticsearch.

-Xms512m: Sets the initial memory allocation pool for the JVM to 512 megabytes (MB). This specifies the minimum amount of memory that Elasticsearch will allocate when it starts up.

-Xmx512m: Sets the maximum memory allocation pool for the JVM to 512 megabytes (MB). This specifies the maximum amount of memory that Elasticsearch can allocate.

Check. https://www.elastic.co/guide/en/elasticsearch/reference/current/advanced-configuration.html#set-jvm-options

Nonsense answered 17/6, 2023 at 20:1 Comment(1)
This is the answer: Its quite silly why this needs to be needed. Expecially when your following a full on tutorial / doc from elastic's website: elastic.co/blog/…Spoilsman
D
1

Docker compose :

  elasticsearch:
    image: elasticsearch:8.8.0
    ports:
      - 9200:9200
      - 9300:9300
    environment:
      - discovery.type=single-node
      - xpack.security.enabled=false
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
Dismember answered 19/3 at 17:44 Comment(0)
N
0

Can you check

ls -ltd elasticsearch-8.3.3

and give output here (about catalog permission).

Nervine answered 2/9, 2022 at 22:0 Comment(0)
C
0

To get around the following error:

ERROR: Elasticsearch exited unexpectedly, with exit code 78

On a Mac M1 arm64 architecture I had to run the following to start a Docker container running the latest elasticsearch image:

docker run -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -e "xpack.security.enabled=false" -d arm64v8/elasticsearch:8.10.3

Thank you to Bret Fisher's Udemy Course on Docker Mastery for the solution here.

Christianly answered 6/11, 2023 at 5:33 Comment(0)
S
0

TLDR:

If you are using THIS website to get a sample starter-compose file with Kibana, Elastic Search and LogStash, you will get "Unexpectedly exited".

https://www.elastic.co/blog/getting-started-with-the-elastic-stack-and-docker-compose

The Solution Is to do add this to the compose file.

environment:
  - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
Spoilsman answered 5/6 at 17:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.