快速启动 elasticsearch
文档说明:只记录关键地方;
试验环境: linux debian 11
elasticsearch + elasticsearch-head
elasticsearch-head 可能需要解决跨域问题,可以使用nginx 反向代理或者 socat 转发 解决。
version: "3"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.7
container_name: "es01"
hostname: "es01"
ports:
- "9200:9200"
- "9300:9300"
environment:
- discovery.type=single-node
- node.name=es01
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
volumes:
- ./data:/usr/share/elasticsearch/data
- ./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
elasticsearch-head: # webUI
image: mobz/elasticsearch-head:5-alpine
ports:
- "9100:9100"
elasticsearch.yml 文件
cluster.name: "docker-cluster"
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
elasticsearch-reset-password
docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-reset-password
启动、关闭、查看日志
# 启动
docker-compose -f docker-compose.yaml up -d
# 关闭
docker-compose -f docker-compose.yaml down --remove-orphans
# 查看日志
docker-compose -f docker-compose.yaml logs -f