docker compose一键部署ElasticSearch7.71.25实战

                                              作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.编写docker-compose文件

version: '3.3'

services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.25
    container_name: es01
    environment:
      - node.name=es01
      - cluster.name=yinzhengjie-linux-es-cluster
      - discovery.seed_hosts=es02,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    # 配置资源限制
    ulimits:
      # 配置内存锁定
      memlock:
        # 软限制,-1代表不限制
        soft: -1
        # 硬限制,-1代表不限制
        hard: -1
    # 参考文档: https://docs.docker.com/reference/compose-file/services/#sysctls
    #sysctls:
    #   vm.max_map_count: 262144
    volumes:
      - data01:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - elastic

  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.25
    container_name: es02
    environment:
      - node.name=es02
      - cluster.name=yinzhengjie-linux-es-cluster
      - discovery.seed_hosts=es01,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    #sysctls:
    #   vm.max_map_count: 262144
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data02:/usr/share/elasticsearch/data
    networks:
      - elastic

  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.25
    container_name: es03
    #sysctls:
    #  vm.max_map_count: 262144
    environment:
      - node.name=es03
      - cluster.name=yinzhengjie-linux-es-cluster
      - discovery.seed_hosts=es01,es02
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data03:/usr/share/elasticsearch/data
    networks:
      - elastic

volumes:
  data01:
    driver: local
  data02:
    driver: local
  data03:
    driver: local

networks:
  elastic:
    driver: bridge

二.启动实例

docker-compose up -d
posted @ 2024-10-31 06:46  尹正杰  阅读(24)  评论(0编辑  收藏  举报