DockerCompose文件
bash
version: '3.1'
services:
elasticsearch:
image: elasticsearch:7.13.3
container_name: elasticsearch
privileged: true
ports:
- "9200:9200"
- "9300:9300"
environment:
- ES_JAVA_OPTS=-Xms128m -Xmx1024m #设置使用jvm内存大小
- cluster.name=elasticsearch #设置集群名称
- discovery.type=single-node #以单一节点模式启动
- bootstrap.memory_lock=true
- http.cors.enabled=true
- http.cors.allow-origin=*
- TZ=Asia/Shanghai
deploy:
resources:
limits:
cpus: "2"
memory: 1000M
reservations:
memory: 200M
ulimits:
memlock:
soft: -1
hard: -1
新建文件夹
bash
/data/docker/es/plugins
/data/docker/es/data
/data/docker/es/logs
把es的内部文件拷贝出来
bash
docker cp elasticsearch:/usr/share/elasticsearch/plugins /opt/docker/data/es/plugins
docker cp elasticsearch:/usr/share/elasticsearch/data /opt/docker/data/es/data
docker cp elasticsearch:/usr/share/elasticsearch/logs /opt/docker/data/es/logs
然后停止容器
删除容器
重新运行yml文件
bash
version: '3.1'
services:
elasticsearch:
image: elasticsearch:7.13.3
container_name: elasticsearch
privileged: true
ports:
- "9200:9200"
- "9300:9300"
environment:
- ES_JAVA_OPTS=-Xms128m -Xmx1024m #设置使用jvm内存大小
- cluster.name=elasticsearch #设置集群名称
- discovery.type=single-node #以单一节点模式启动
- bootstrap.memory_lock=true
- http.cors.enabled=true
- http.cors.allow-origin=*
- TZ=Asia/Shanghai
volumes:
- /opt/docker/data/es/plugins:/usr/share/elasticsearch/plugins #插件文件挂载
- /opt/docker/data/es/data:/usr/share/elasticsearch/data #数据文件挂载
- /opt/docker/data/es/logs:/user/share/elasticsearch/logs
deploy:
resources:
limits:
cpus: "2"
memory: 1000M
reservations:
memory: 200M
ulimits:
memlock:
soft: -1
hard: -1