25

I am getting this error:

es01 | {"type": "server", "timestamp": "2019-09-18T17:31:42,267+0000", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "docker-cluster", "node.name": "es01", "message": "starting ..." } es01 | {"type": "server", "timestamp": "2019-09-18T17:31:42,709+0000", "level": "INFO", "component": "o.e.t.TransportService", "cluster.name": "docker-cluster", "node.name": "es01", "message": "publish_address {172.21.0.3:9300}, bound_addresses {0.0.0.0:9300}" } es01 | {"type": "server", "timestamp": "2019-09-18T17:31:42,760+0000", "level": "INFO", "component": "o.e.b.BootstrapChecks", "cluster.name": "docker-cluster", "node.name": "es01", "message": "bound or publishing to a non-loopback address, enforcing bootstrap checks" }

the error that matters:

ERROR: [1] bootstrap checks failed es01 | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

and then the node stops because of the above error:

es01 | {"type": "server", "timestamp": "2019-09-18T17:31:42,810+0000", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "docker-cluster", "node.name": "es01", "message": "stopping ..." } es01 | {"type": "server", "timestamp": "2019-09-18T17:31:42,904+0000", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "docker-cluster", "node.name": "es01", "message": "stopped" } es01 | {"type": "server", "timestamp": "2019-09-18T17:31:42,905+0000", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "docker-cluster", "node.name": "es01", "message": "closing ..." } es01 | {"type": "server", "timestamp": "2019-09-18T17:31:42,967+0000", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "docker-cluster", "node.name": "es01", "message": "closed" } es01 | {"type": "server", "timestamp": "2019-09-18T17:31:42,976+0000", "level": "INFO", "component": "o.e.x.m.p.NativeController", "cluster.name": "docker-cluster", "node.name": "es01", "message": "Native controller process has stopped - no new native processes can be started" }

my docker-compose.yml file is as follows:

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 -Xmx512m"
    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 -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata02:/usr/share/elasticsearch/data

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

does anyone know how I can increase the memory of the cluster and fix the error?

  • 2
    If you need to run this for **WSL2** then open power shell `wsl.exe -u root` , execute the command `sysctl -w vm.max_map_count=262144`, `exit` - Recreate the docker images. Viola. – Piotr Kula Jan 25 '22 at 10:59

2 Answers2

48

looks like the solution is to use: https://github.com/docker-library/elasticsearch/issues/111

which suggests running this on ubuntu:

sudo sysctl -w vm.max_map_count=262144
  • Thanks, this also resolves issue on AWS Linux (redhat based) when following ES 8.5.3 "Install Elasticsearch with Docker" document. – Levin Magruder Jan 07 '23 at 19:43
27

If you closely follow the official Elasticsearch Docker documentation.

You need to set the vm.max_map_count check this here.

halfer
  • 19,824
  • 17
  • 99
  • 186
mchawre
  • 10,744
  • 4
  • 35
  • 57
  • The instructions for Mac don't work. `screen` gives me `Cannot exec '/Users/arielpontes/Library/Containers/com.docker.docker/Data/vms/0/tty': Permission denied` and `sudo` doesn't work. `chmod 777` does work but then when I run the command my terminal window blinks and I get `[screen is terminating]`. When I try `sysctl -w vm.max_map_count=262144` I get `sysctl: unknown oid 'vm.max_map_count'`. – Ariel Dec 15 '20 at 13:40
  • 2
    Thanks! I think documentation should mention that earlier. As it is first mentioned in section 6.1 and it can be an issue when following instructions on section 3. – Javier Paz Sedano Mar 31 '22 at 12:46
  • Maybe the docs have made some changes, the setting's here now: https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#_set_vm_max_map_count_to_at_least_262144 – WISERDIVISOR Feb 14 '23 at 11:31