Change Heap Size for Elastic Search


Change Heap Size for Elastic Search

The default installation of Elasticsearch is configured with a 1 GB heap. For just about every deployment, this number is usually too small. If you are using the default heap values, your cluster is probably configured incorrectly.

There are two ways to change the heap size in Elasticsearch. The easiest is to set an environment variable called ES_HEAP_SIZE. When the server process starts, it will read this environment variable and set the heap accordingly. As an example, you can set it via the command line as follows:

export ES_HEAP_SIZE=10g

Alternatively, you can pass in the heap size via JVM flags when starting the process, if that is easier for your setup:

ES_JAVA_OPTS="-Xms10g -Xmx10g" ./bin/elasticsearch 

Ensure that the min (Xms) and max (Xmx) sizes are the same to prevent the heap from resizing at runtime, a very costly process.

sudo vi /etc/elasticsearch/jvm.options

Generally, setting the ES_HEAP_SIZE environment variable is preferred over setting explicit -Xmx and -Xms values.

Source: https://www.elastic.co/guide/en/elasticsearch/guide/current/heap-sizing.html See also Setting JVM options. There are two ways to change the heap size in Elasticsearch. The easiest is to set an environment variable called ES_HEAP_SIZE.

Full disk space problems

  1. You could try to remove indexes
$ curl -XDELETE http://localhost:9200/PATTERN_OR_PATH

Replace PATTERN_OR_PATH with the pattern or index that you want to remove.

To remove all indexes:

$ curl -XDELETE http://localhost:9200/*
  1. Remove .hprof files

# got to cd /var/lib/elasticsearch/
$ cd cd /var/lib/elasticsearch/

# show all files

[email protected]:/var/lib/elasticsearch# ls -lh
total 29138560
-rw------- 1 elasticsearch elasticsearch 1175937553 Mar  7 12:01 java_pid19447.hprof
-rw------- 1 elasticsearch elasticsearch 1459518773 Apr  1 07:10 java_pid20206.hprof
drwxr-sr-x 3 elasticsearch elasticsearch       4096 Oct 29  2019 nodes


# remove unwanted files

$ rm java_pid19447.hprof

Newsletter


Related Posts

Get your Jenkins Passwords from secrets

How to get your Jenkins passwords from your secrets credentials. Follow this simple tutoriale and find your password or ssh private key.

How to launch a 6 figures startup with 0$ investment

Are you curious how to launch a startup in the fast and effective way? Here's not the answer, but you can understand how to achieve it

How to cold email

How to cold email - a practical guide about how to use cold email in your activity as a CEO of a software agency or startup owner.

Linux disk space alerts on Discord

Linux disk space alerts. Check your space and be responsible with your project. Take care of your space and don't crack the project.

Git clone private repo in docker

A simple how to guide to use git clone of a private repository inside docker container. With vuejs / nodejs app.

How to detect the browser language in javascript

How to detect the browser language in javascript in just a line of code. The method is working on all major browser

You don't need a macbook pro to be a pro

You don't need a macbook pro to be a pro! You need a laptop and internet connection, and a brain, but you already have it

Free templates for startup

Free HTML templates for startup or a new project. A complete list with free resources to build your next startup's website and gain the traction to the sky.

What I learned to never do in a presentation meeting

What I learned to never do in a presentation meeting. I had a very bad meeting experience with a gateway provider.

Startup graveyard is a series of killed projects that made millions in revenue per year

Startup graveyard is a series of killed projects that made millions in revenue per year. Just watch their graveyard and do it your own. What better validation do you expect.