0

im trying to start a elasticsearch instance for dev porpuse(the smallest possible , dont care), is inside ec2 t2.micro (in order to avoid cost running the elasticsearch service from aws)

so ... i pulled the instance

docker pull docker.elastic.co/elasticsearch/elasticsearch:6.8.9

enter image description here

now , when i try to run the image

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.8.9

the following error apperars

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c0000000, 1073741824, 0) 

    failed; error='Not enough space' (errno=12)
    #
    # There is insufficient memory for the Java Runtime Environment to continue.
    # Native memory allocation (mmap) failed to map 1073741824 bytes for committing reserved memory.
    # An error report file with more information is saved as:
    # logs/hs_err_pid1.log

i heard in some places that you have two options Either give more memory to your VM (is this posible for a t2.micro instance), how can achive that? or change Elasticsearch JVM settings/etc/elasticsearch/jvm.options and lower the values of the following parameters -Xms512m -Xmx512m but how can i do this if i the image its not available to get in

i also tried to install elasticserach via rpm but requires coreutils >= 8.4 , so another failure trying to get the instance up

using -Xms512m -Xmx512m on jvm.options with avaible space (i guess) i got the same error Not enough space enter image description here

1 Answers1

2

You are on right right track. t2.micro instances only have 1 GiB of memory, so you either need to upgrade your VM or lower the JVM settings.

To bind mount the jvm options file, you can use the -v option. So when starting the container, you would add something like this to the docker command:

<docker run command> -v local/jvm.options:/etc/elasticsearch/jvm.options docker.elastic.co/elasticsearch/elasticsearch:6.8.9

Where local/jvm.options contains your specified JVM options as a file on the EC2 instance.

For more information about bing mounting, you can see the documentation here

Dennis
  • 415
  • 4
  • 13
  • i did run sudo docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.8.9 -v local/jvm.options:/etc/elasticsearch/jvm.option error => basename: invalid option -- 'v' where local/jvm.options has -Xms521m -Xmx521m – Guillermo Nahuel Varelli May 17 '20 at 00:16
  • 1
    Move the -v option before the image name: sudo docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -v local/jvm.options:/etc/elasticsearch/jvm.option docker.elastic.co/elasticsearch/elasticsearch:6.8.9 – Dennis May 17 '20 at 00:29
  • Also, local/jvm.options was just an example, you can use any file name you want. Just make sure you give the absolute path. – Dennis May 17 '20 at 00:30
  • could you please check the last updated at the bottom? the docker comman runs and i guess with available space but i got the same error of space – Guillermo Nahuel Varelli May 17 '20 at 01:05
  • @GuillermoNahuelVarelli, https://stackoverflow.com/questions/61589254/why-docker-image-with-elasticsearch-status-restarting-always answers your question. – Amit May 17 '20 at 01:52