zoukankan      html  css  js  c++  java
  • docker compose es集群

    创建目录及文件

    tree .
    
    .
    ├── docker-compose.yml
    └── elasticsearch
        ├── config
        │   └── elasticsearch.yml
        ├── data1
        ├── data2
        ├── data3
        └── Dockerfile

    dockerfile:

    ARG ELK_VERSION=7.5.1
    
    # https://github.com/elastic/elasticsearch-docker
    # FROM docker.elastic.co/elasticsearch/elasticsearch:${ELK_VERSION}
    FROM elasticsearch:${ELK_VERSION}
    # Add your elasticsearch plugins setup here
    # Example: RUN elasticsearch-plugin install analysis-icu

    elasticsearch.yml

    ## Default Elasticsearch configuration from Elasticsearch base image.
    ## https://github.com/elastic/elasticsearch/blob/master/distribution/docker/src/docker/config/elasticsearch.yml
    #
    cluster.name: "es-docker-cluster"
    network.host: 0.0.0.0
    
    ## X-Pack settings
    ## see https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-xpack.html
    #
    xpack.license.self_generated.type: basic                               #trial为试用版,一个月期限,可更改为basic版本
    xpack.security.enabled: false
    xpack.monitoring.collection.enabled: false
    
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

    docker-compose.yml

    version: '3.7'
    services:
      es01:
        build:
          context: /Users/xxx/docker/elasticsearch/
          args:
            ELK_VERSION: 7.5.1
        container_name: es01
        volumes:
          - type: bind
            source: /Users/xxx/docker/elasticsearch/config/elasticsearch.yml
            target: /usr/share/elasticsearch/config/elasticsearch.yml
            read_only: true
          - type: volume
            source: data01
            target: /usr/share/elasticsearch/data
        ports:
          - 9200:9200
        environment:
          - node.name=es01
          - cluster.name=es-docker-cluster
          - discovery.seed_hosts=es02,es03
          - cluster.initial_master_nodes=es01,es02,es03
          - bootstrap.memory_lock=true
          - node.master=true
          - node.data=true
          - http.port=9200
          - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
        ulimits:
          memlock:
            soft: -1
            hard: -1
        networks:
          - elastic
      es02:
        build:
          context: /Users/xxx/docker/elasticsearch/
          args:
            ELK_VERSION: 7.5.1
        container_name: es02
        volumes:
          - type: bind
            source: /Users/xxx/docker/elasticsearch/config/elasticsearch.yml
            target: /usr/share/elasticsearch/config/elasticsearch.yml
            read_only: true
          - type: volume
            source: data02
            target: /usr/share/elasticsearch/data
        ports:
          - 9201:9201
        environment:
          - node.name=es02
          - cluster.name=es-docker-cluster
          - discovery.seed_hosts=es01,es03
          - cluster.initial_master_nodes=es01,es02,es03
          - bootstrap.memory_lock=true
          - node.master=true
          - node.data=true
          - http.port=9201
          - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
        ulimits:
          memlock:
            soft: -1
            hard: -1
        networks:
          - elastic
      es03:
        build:
          context: /Users/xxx/docker/elasticsearch/
          args:
            ELK_VERSION: 7.5.1
        container_name: es03
        volumes:
          - type: bind
            source: /Users/xxx/docker/elasticsearch/config/elasticsearch.yml
            target: /usr/share/elasticsearch/config/elasticsearch.yml
            read_only: true
          - type: volume
            source: data03
            target: /usr/share/elasticsearch/data
        ports:
          - 9202:9202
        environment:
          - node.name=es03
          - cluster.name=es-docker-cluster
          - discovery.seed_hosts=es01,es02
          - cluster.initial_master_nodes=es01,es02,es03
          - bootstrap.memory_lock=true
          - node.master=true
          - node.data=true
          - http.port=9202
          - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
        ulimits:
          memlock:
            soft: -1
            hard: -1
        networks:
          - elastic
    
    volumes:
      data01:
        driver: local
        driver_opts:
          type: none
          o: bind
          device: /Users/xxx/docker/elasticsearch/data1
    
      data02:
        driver: local
        driver_opts:
          type: none
          o: bind
          device: /Users/xxx/docker/elasticsearch/data2
    
      data03:
        driver: local
        driver_opts:
          type: none
          o: bind
          device: /Users/xxx/docker/elasticsearch/data3
    
    networks:
      elastic:
        driver: bridge

    运行:

    docker-compose up --build -d

    验证:

    浏览器里访问

    在浏览器地址栏访问http://localhost:9200/_cat/nodes?pretty 查看节点状态

    使用elasticsearch-head前端框架

    docker pull mobz/elasticsearch-head:5-alpine
    docker run -d -p 9100:9100 --name es-head  mobz/elasticsearch-head:5-alpine

    浏览器访问http://localhost:9100/

    参考

    https://www.cnblogs.com/caibao666/p/12753274.html






    首页:

      raindream

    GitHub:

      https://github.com/rain-bjtu


  • 相关阅读:
    linux批量远程多服务器FTP并下载文件的脚本
    NPM更换国内源
    Win10禁用无用的服务
    JS测试
    FastAdmin导出
    VScode全局设置
    Vue路由history模式
    kill_devtmpfsi
    获取域名URL
    Axios去除Respones中的config、headers、request
  • 原文地址:https://www.cnblogs.com/drizzlewithwind/p/15090171.html
Copyright © 2011-2022 走看看