banner
 Sayyiku

Sayyiku

Chaos is a ladder
telegram
twitter

Deploying Elasticsearch with Docker

Requires the installation of docker service on the host machine.

  • Use the elasticsearch:7.10.1 image.
- Mount the main configuration file (the main configuration file enables xpack authentication)
- Mount the data directory
- Mount the log file
- Set the cluster mode to single-node
- Set the memory size used by es
  • Modify the parameters according to the actual situation.
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 Information##

Directory Information##

# 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 Information##

# 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

Execute docker command to start the container##

  • Modify the parameters according to the actual situation.
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

Start xpack authentication##

# docker exec -it elasticsearch bash
# elasticsearch-setup-passwords interactive

.... Set passwords for 6 es_xpack authentication accounts ....
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.