213 字
1 分钟
Deploying Elasticsearch with Docker
You need to have the docker service installed on the host.
- Use the
elasticsearch:7.10.1image
- 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
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.1Server Directory Configuration Info#
Directory Info#
# 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 -RConfiguration Info#
# vim /data/elasticsearch/elasticsearch.ymlcluster.name: "test_evescn"network.host: 0.0.0.0#xpack.security.enabled: truehttp.cors.allow-headers: Authorizationxpack.security.enabled: truexpack.security.transport.ssl.enabled: trueRun the docker command to start the container#
- You can adjust the parameters as needed
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.1Enable xpack authentication#
# 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