DockerCompose文件
version: '3.1'
services:elasticsearch:image: elasticsearch:7.13.3container_name: elasticsearchprivileged: trueports:- "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/Shanghaideploy:resources:limits:cpus: "2"memory: 1000Mreservations:memory: 200Mulimits:memlock:soft: -1hard: -1
新建文件夹
/data/docker/es/plugins
/data/docker/es/data
/data/docker/es/logs
把es的内部文件拷贝出来
docker cp elasticsearch:/usr/share/elasticsearch/plugins /opt/docker/data/es/pluginsdocker cp elasticsearch:/usr/share/elasticsearch/data /opt/docker/data/es/datadocker cp elasticsearch:/usr/share/elasticsearch/logs /opt/docker/data/es/logs
然后停止容器
删除容器
重新运行yml文件
version: '3.1'
services:elasticsearch:image: elasticsearch:7.13.3container_name: elasticsearchprivileged: trueports:- "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/Shanghaivolumes:- /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/logsdeploy:resources:limits:cpus: "2"memory: 1000Mreservations:memory: 200Mulimits:memlock:soft: -1hard: -1
部署成功访问
http://服务器id:9200/