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

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

Resources to generate free legal pages for your website

Are you looking for resources to generate free legal pages for your website

Netopiajs library for nodejs

Unofficial library of Netopia to integrate with Nodejs

Where to find free assets and images list

Find a multitude of places with free assets and images for your project

Convert bson file to json with javascript

How to convert bson file to json with javascript with a simple script file

Managerflota idea validation

Managerflota idea validation thread. Manage the car hailing business in one web app.

Generate hexagons in JS based on center coordinates and radius

How to generate hexagons in javascript based on the center point coordinates and radius length

How to generate referral codes in javascript

How to generate referral codes in javascript very fast with less code

Loop over directories in bash and execute commands

How to loop over directories in bash and execute multiple commands

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.