• 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


  • 相关阅读:
    STM32对HAL库的LCD驱动移植
    stm32对HAL库的DAC使用
    STM32对HAL库的ADC(多通道DMA)
    STM32对HAL库的ADC(单通道非DMA)
    STM32 fputc函数(重定向)
    STM32的HAL库DMA串口不定长度的读写操作(二)
    STM32对HAL库的PWM控制
    STM32对HAL库的定时器中断
    STM32对HAL库的外部中断处理
    C#上位机制作之串口接受数据(利用接受事件)
  • 原文地址:https://www.cnblogs.com/drizzlewithwind/p/15090171.html
Copyright © 2020-2023  润新知