ElasticSearch Deploy with docker

Elastic Search Depoly Note

1. Persistent Data and config folder as if when docker exit, the file can be persistent.

1
2
3
4
5
6
mkdir /usr/share/elasticsearch/config
mkdir /usr/share/elasticsearch/data
chgrp 0 /usr/share/elasticsearch/data
chgrp 0 /usr/share/elasticsearch/config
chmod g+rwx /usr/share/elasticsearch/data
chmod g+rwx /usr/share/elasticsearch/config

Docker store keystore first before run:

1
2
3
4
5
docker run -it --rm \
-v /usr/share/elasticsearch/config:/usr/share/elasticsearch/config \
-v :/usr/share/elasticsearch/data:/usr/share/elasticsearch/data \
docker.elastic.co/elasticsearch/elasticsearch:8.6.2 \
bin/elasticsearch-keystore create -p

Terminal should be respond like this:

1
2
3
Enter new password for the elasticsearch keystore (empty for no password):
Enter same password again:
Created elasticsearch keystore in /usr/share/elasticsearch/config/elasticsearch.keystore

2. Create network and reset the password to bind kibana.

  • Create network for elastic:

docker network create elastic

  • Run elastic
1
2
3
docker run -it --name es01 \
        --net elastic -p 9200:9200 \
        docker.elastic.co/elasticsearch/elasticsearch:8.6.2

Error ancounterd as follow:

1
2
3
4
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
....
....
ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
  • Add max memory map to sysctl.conf
1
vm.max_map_count = 262144
  • Restart container using docker start es01

3. If elastic successfully run, reset the password for elastic.

1
docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic
  • If terminal output like this:
1
ERROR: unable to create temporary keystore at [/usr/share/elasticsearch/config/elasticsearch.keystore.tmp], write permissions required for [/usr/share/elasticsearch/config] or run [elasticsearch-keystore upgrade]

Try reset your file permissions.

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
33135a60-master at 2024-03-09 15:10:22 +0000
Built with Hugo
Theme Stack designed by Jimmy