docker-compose安装elk

2023-05-19 17:45:23 浏览数 (3)

# 安装文件

代码语言:javascript复制
version: "3"
services:
  es-master:
    container_name: es-master
    hostname: es-master
    image: elasticsearch:7.12.1
    restart: always
    ports:
      - 9200:9200
      - 9300:9300
    volumes:
      - ./elasticsearch/master/conf/es-master.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - /data/elk/es-master/data:/usr/share/elasticsearch/data
      - /data/elk/es-master/logs:/usr/share/elasticsearch/logs
      - /etc/localtime:/etc/localtime
      - ./elastic-certificates.p12:/usr/share/elasticsearch/config/elastic-certificates.p12
    environment:
      - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
    ulimits:
      memlock:
        soft: -1
        hard: -1

  es-slave1:
    container_name: es-slave1
    image: elasticsearch:7.12.1
    restart: always
    ports:
      - 9201:9200
      #- 9301:9300
    volumes:
      - ./elasticsearch/slave1/conf/es-slave1.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - /data/elk/es-slave1/data:/usr/share/elasticsearch/data
      - /data/elk/es-slave1/logs:/usr/share/elasticsearch/logs
      - /etc/localtime:/etc/localtime
      - ./elastic-certificates.p12:/usr/share/elasticsearch/config/elastic-certificates.p12
    environment:
      - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
    ulimits:
      memlock:
        soft: -1
        hard: -1

  es-slave2:
    container_name: es-slave2
    image: elasticsearch:7.12.1
    restart: always
    ports:
      - 9202:9200
      #- 9302:9300
    volumes:
      - ./elasticsearch/slave2/conf/es-slave2.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - /data/elk/es-slave2/data:/usr/share/elasticsearch/data
      - /data/elk/es-slave2/logs:/usr/share/elasticsearch/logs
      - /etc/localtime:/etc/localtime
      - ./elastic-certificates.p12:/usr/share/elasticsearch/config/elastic-certificates.p12
    environment:
      - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
    ulimits:
      memlock:
        soft: -1
        hard: -1

  kibana:
    container_name: kibana
    hostname: kibana
    image: kibana:7.12.1
    restart: always
    ports:
      - 5601:5601
    volumes:
      - ./kibana/conf/kibana.yml:/usr/share/kibana/config/kibana.yml
      - /etc/localtime:/etc/localtime
    environment:
      - elasticsearch.hosts=http://es-master:9200
    depends_on:
      - es-master
      - es-slave1
      - es-slave2
  logstash:
    container_name: logstash
    hostname: logstash
    image: logstash:7.12.1
    command: logstash -f ./conf/logstash-kafka.conf
    restart: always
    volumes:
      # 映射到容器中
      - ./logstash/conf/logstash-kafka.conf:/usr/share/logstash/conf/logstash-kafka.conf
      - ./logstash/ssl:/usr/share/logstash/ssl
      - ./logstash/template:/template
    environment:
      - elasticsearch.hosts=http://es-master:9200
      - /etc/localtime:/etc/localtime
      # 解决logstash监控连接报错
      - xpack.monitoring.elasticsearch.hosts=http://es-master:9200
      - xpack.monitoring.elasticsearch.username="logstash_system"
      - xpack.monitoring.elasticsearch.password="xxx"
    ports:
      - 5044:5044
    depends_on:
      - es-master
      - es-slave1
      - es-slave2

0 人点赞