[docker-compose]ELK单机版日志安装带有x-pa

2020-11-05  本文已影响0人  范er_er

1.docker安装步骤

- 阿里云源地址(**推荐**)

  ```
  sudo yum-config-manager \
      --add-repo \
      http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  ```

- 清华大学源(**推荐**)

  ```
  sudo yum-config-manager \
      --add-repo \
      https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
  
  ```

2.Compose 安装

sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version

3.ELK安装

version: '3'
services:
  elasticsearch:
    image: elasticsearch:6.8.0
    container_name: elasticsearch 
    environment:
      - "cluster.name=elasticsearch" #设置集群名称为elasticsearch
      - "discovery.type=single-node" #以单一节点模式启动
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m" #设置使用jvm内存大小
      - TZ=Asia/Shanghai
    volumes:
      - /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins #插件文件挂载
      - /mydata/elasticsearch/data:/usr/share/elasticsearch/data #数据文件挂载
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - elk
  kibana:
    image: kibana:6.8.0
    container_name: kibana
    links:
      - elasticsearch:es  #可以用es这个域名访问elasticsearch服务
    depends_on:
      - elasticsearch   #kibana在elasticsearch启动之后再启动
    environment:
      - "elasticsearch.hosts=http://es:9200" #设置访问elasticsearch的地址
      - TZ=Asia/Shanghai
    ports:
      - 5601:5601
    networks:
      - elk
  logstash:
    image: logstash:6.8.0
    container_name: logstash
    environment:
      - TZ=Asia/Shanghai
    volumes:
      - /mydata/logstash/logstash.conf:/usr/share/logstash/pipeline/logstash.conf #挂载logstash的配置文件
    depends_on:
      - elasticsearch #kibana在elasticsearch启动之后再启动
    links:
      - elasticsearch:es #可以用es这个域名访问elasticsearch服务
    ports:
      - 4560:4560
      - 4561:4561
      - 4562:4562
      - 4563:4563
    networks:
      - elk
networks:   #设置同一网段
  elk:
    driver: bridge
上一篇 下一篇

猜你喜欢

热点阅读