docker-compose一键部署elasticsearch6.8.12单点

docker部署elasticsearch

目录规划:

应用目录: /usr/local/elasticsearch
数据目录: /data/elasticsearch/

mkdir /data/elasticsearch/ -p
mkdir /usr/local/elasticsearch -p

编辑/data/elasticsearch/config/elasticsearch.yml配置文件

cluster.name: "elasticsearch-cluster"
network.host: 0.0.0.0
transport.port: 48809
http.port: 48808
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.ml.enabled: false
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: false

创建docker-compose.yml示例文件如下:

docker-compose.yml
version: '3'
services:
  elasticsearch:
    image: docker.io/elasticsearch:6.8.12
    container_name: elasticsearch
    restart: always
    environment:
      - cluster.name=elasticsearch-cluster
      - bootstrap.memory_lock=true
      - http.cors.enabled=true
      - http.cors.allow-origin=*
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
    volumes:
      - /data/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
      - /data/elasticsearch/data:/usr/share/elasticsearch/data:rw
      - /data/elasticsearch/logs:/user/share/elasticsearch/logs:rw
      - /data/elasticsearch/plugins:/usr/share/elasticsearch/plugins:rw
      - /etc/localtime:/etc/localtime:rw
    network_mode: host

目录赋权

chown -R 1000.1000 /data/elasticsearch/

启动服务

docker-compose -f docker-compose.yaml up -d

生成密码,注意自行复制保存生成的所有账户密码信息

docker exec -it 5c2cbc9f058d /bin/bash
elasticsearch-setup-passwords auto
posted @ 2023-03-15 11:21  也曾少年  阅读(74)  评论(0编辑  收藏  举报