user11810894
user11810894

Reputation:

Increase heapsize of docker-compose container

I am getting this error in my docker-compose logs upon boot:

es02 | ERROR: [1] bootstrap checks failed es02 | [1]: initial heap size [536870912] not equal to maximum heap size [2644508672]; this can cause resize pauses and prevents mlockall from locking the entire heap

my docker-compose.yml is:

version: '2.2'
services:
  kibana:
    depends_on:
      - es01
      - es02
    image: docker.elastic.co/kibana/kibana:7.3.1
    container_name: kibana
    ports:
      - 5601:5601
    environment:
      ELASTICSEARCH_HOSTS: http://es01:9200
      ELASTICSEARCH_URL: http://es01:9200
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.3.1
    container_name: es01
    environment:
      - node.name=es01
      - discovery.seed_hosts=es02
      - cluster.initial_master_nodes=es01,es02
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx2524m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
      - 9300:9300
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.3.1
    container_name: es02
    environment:
      - node.name=es02
      - discovery.seed_hosts=es01
      - cluster.initial_master_nodes=es01,es02
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx2524m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata02:/usr/share/elasticsearch/data

volumes:
  esdata01:
    driver: local
  esdata02:
    driver: local

I know what causes the problem - it's that I used -Xmx2524m...if I change those to -Xmx512m it works fine. Does anyone know how I can safely increase the max heap size?

Upvotes: 2

Views: 2889

Answers (1)

Zakaria El Achham
Zakaria El Achham

Reputation: 21

Increase it both -Xms and -Xmx

Set it, for example, to 1G:

- "ES_JAVA_OPTS=-Xms1g -Xmx1g"

Upvotes: 2

Related Questions