213 字
1 分钟

Deploying Elasticsearch with Docker

You need to have the docker service installed on the host.

  • Use the elasticsearch:7.10.1 image
Terminal window
- Mount the main configuration file (xpack authentication is enabled in the main config)
- Mount the data directory
- Mount the log directory
- Set the cluster mode to single-node
- Configure the memory size used by ES
  • You can adjust the parameters as needed
Terminal window
docker run -d --restart=always --user=root \
--privileged=true \
--name elasticsearch \
-p 9200:9200 \
-p 9300:9300 \
--ulimit nofile=65536:65536 \
-v "/data/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml" \
-v "/data/elasticsearch/data":/usr/share/elasticsearch/data \
-v "/data/elasticsearch/logs":/usr/share/elasticsearch/logs \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms8G -Xmx8G" \
elasticsearch:7.10.1

Server Directory Configuration Info##

Directory Info##

Terminal window
# tree /data/elasticsearch/ -L 1
/data/elasticsearch/
├── data # data directory
├── elasticsearch.yml # configuration file
└── logs # logs
# mkdir /data/elasticsearch/{data,logs} -pv
# cd /data/
# chown 1000 elasticsearch -R

Configuration Info##

Terminal window
# vim /data/elasticsearch/elasticsearch.yml
cluster.name: "test_evescn"
network.host: 0.0.0.0
#xpack.security.enabled: true
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

Run the docker command to start the container##

  • You can adjust the parameters as needed
Terminal window
docker run -d --restart=always --user=root \
--privileged=true \
--name elasticsearch \
-p 9200:9200 \
-p 9300:9300 \
--ulimit nofile=65536:65536 \
-v "/data/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml" \
-v "/data/elasticsearch/data":/usr/share/elasticsearch/data \
-v "/data/elasticsearch/logs":/usr/share/elasticsearch/logs \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms8G -Xmx8G" \
elasticsearch:7.10.1

Enable xpack authentication##

Terminal window
# docker exec -it elasticsearch bash
# elasticsearch-setup-passwords interactive
.... Set passwords for the 6 es_xpack authentication accounts ....
Deploying Elasticsearch with Docker
https://catcat.blog/en/docker-install-elasticsearch.html
作者
猫猫博客
发布于
2023-05-18
许可协议
CC BY-NC-SA 4.0