跳转到主要内容

elasticsearch

version: '3'
services:
  elasticsearch-1:
    image: swr.cn-south-1.myhuaweicloud.com/vp-whdev/all-in-devops/elasticsearch:8.8.0
    restart: always
    ports:
      - 9200:9200
      - 9300:9300
    privileged: true
    environment:
      - node.name=es01                                            # 节点名称,唯一
      - cluster.name=gzrqjt-log                                   # 集群名称,集群一致
      - cluster.initial_master_nodes=es01,es02                    # 集群节点成员
      - discovery.seed_hosts=elasticsearch-2                      # 从指定主机发现
      - xpack.security.enabled=false                              # xpack 安全设置
      - xpack.security.http.ssl.enabled=false                     # xpack 安全设置	
      # - discovery.type=single-node # 单节点
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
    volumes:
      - ./data1:/usr/share/elasticsearch/data
    # extra_hosts:
    #   - "elasticsearch-2:172.18.41.2"  
    networks:
      - elasticsearch-net
  elasticsearch-2:
    image: swr.cn-south-1.myhuaweicloud.com/vp-whdev/all-in-devops/elasticsearch:8.8.0
    restart: always
    # ports:
    #   - 9200:9200
    #   - 9300:9300
    privileged: true
    environment:
      - node.name=es02                                            # 节点名称,唯一
      - cluster.name=gzrqjt-log                                   # 集群名称,集群一致
      - cluster.initial_master_nodes=es01,es02,es03               # 集群节点成员
      - discovery.seed_hosts=elasticsearch-2,elasticsearch-3      # 从指定主机发现
      - xpack.security.enabled=false                              # xpack 安全设置
      - xpack.security.http.ssl.enabled=false                     # xpack 安全设置	
      # - discovery.type=single-node # 单节点
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
    volumes:
      - ./data2:/usr/share/elasticsearch/data
    # extra_hosts:
    #   - "elasticsearch-2:172.18.41.2"  
    networks:
      - elasticsearch-net

  elasticsearch-3:
    image: swr.cn-south-1.myhuaweicloud.com/vp-whdev/all-in-devops/elasticsearch:8.8.0
    restart: always
    # ports:
    #   - 9200:9200
    #   - 9300:9300
    privileged: true
    environment:
      - node.name=es03                                            # 节点名称,唯一
      - cluster.name=gzrqjt-log                                   # 集群名称,集群一致
      - cluster.initial_master_nodes=es01,es02,es03               # 集群节点成员
      - discovery.seed_hosts=elasticsearch-2,elasticsearch-3      # 从指定主机发现
      - xpack.security.enabled=false                              # xpack 安全设置
      - xpack.security.http.ssl.enabled=false                     # xpack 安全设置	
      # - discovery.type=single-node # 单节点
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
    volumes:
      - ./data3:/usr/share/elasticsearch/data
    # extra_hosts:
    #   - "elasticsearch-2:172.18.41.2"  
    networks:
      - elasticsearch-net

networks:
  elasticsearch-net:
    external:
      name: elasticsearch-net    


# docker network create --subnet=172.20.100.0/24 --gateway 172.16.100.1 elasticsearch-net

# groupadd elasticsearch                                    # 增加用户组
# useradd elasticsearch -g elasticsearch -p codingwhy$@&*     # 增加用户

# chown -R elasticsearch:elasticsearch data1/               # 修改权限
# chmod 755 data1/                                          # 修改权限
# vi /etc/sysctl.conf
# vm.max_map_count=262144                                   # 设置进程拥有的内存大小,永久生效
# sysctl -w vm.max_map_count=262144                         # 设置进程拥有的内存大小,一次生效
```yaml