需要宿主機安裝 docker
服務
- 使用
elasticsearch:7.10.1
鏡像
- 掛載了主配置文件(主配置文件中啟用了xpack認證)
- 掛載了 data 數據目錄
- 掛載了 log 日誌文件
- 設置集群模式為 single-node
- 設置了 es 使用的內存大小
- 可根據實際情況修改參數
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
伺服器目錄配置資訊##
目錄資訊##
# tree /data/elasticsearch/ -L 1
/data/elasticsearch/
├── data # 數據目錄
├── elasticsearch.yml # 配置文件
└── logs # 日誌
# mkdir /data/elasticsearch/{data,logs} -pv
# cd /data/
# chown 1000 elasticsearch -R
配置資訊##
# 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
執行 docker 命令啟動容器##
- 可根據實際情況修改參數
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
啟動 xpack 認證##
# docker exec -it elasticsearch bash
# elasticsearch-setup-passwords interactive
.... 設置 es_xpack 認證的6個帳戶密碼 ....