docker-compose部署ELK(亲测)

Posted dalianpai

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker-compose部署ELK(亲测)相关的知识,希望对你有一定的参考价值。

具体的配置可以参考上面一篇:docker部署ELK

以下是做了一些修改的地方:

kibana.yml

[root@topcheer config]# cat kibana.yml
server.host: "0.0.0.0"
elasticsearch.url: http://elasticsearch01:9200
xpack:
  apm.ui.enabled: false
  graph.enabled: false
  ml.enabled: false
  monitoring.enabled: false
  reporting.enabled: false
  security.enabled: false
  grokdebugger.enabled: false
  searchprofiler.enabled: false
[root@topcheer config]#

logstash的conf

[root@topcheer pipeline]# cat logstash-test.conf
input {
    file {
        path => ["/usr/share/logstash/pipeline/logs/test.log"]
        start_position => "beginning"
    }
}
output {
   elasticsearch { hosts => ["elasticsearch01:9200"] }
}
[root@topcheer pipeline]#

别的配置都没有变,然后新增docker-compose.yml

[root@topcheer config]# cat docker-compose.yml
version: ‘2‘
services:
  elasticsearch01: #服务名称(不是容器名,名称最好不要含有特殊字符,碰到过用下划线时运行出错)
    image: docker.elastic.co/elasticsearch/elasticsearch:6.4.3
    container_name: elasticsearch01 #容器名称 
    volumes: #挂载文件
      - ./elasticsearch/logs/:/usr/share/logs/
      - /elk/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
    ports:
      - "9200:9200" #暴露的端口信息和docker run -d -p 80:80一样
      - "9300:9300"
    environment: #设置镜像变量,它可以保存变量到镜像里面
      ES_JAVA_OPTS: "-Xmx512m -Xms512m"
    networks: #加入指定网络
      - elk
  logstash_test:
    image: docker.elastic.co/logstash/logstash:6.4.3
    container_name: logstash01
    volumes:
      - /elk/config/logstash/config/:/usr/share/logstash/config/:ro
      - /elk/config/logstash/pipeline/:/usr/share/logstash/pipeline/
    ports:
      - "5044:5044"
      - "9600:9600"
    environment:
      LS_JAVA_OPTS: "-Xmx512m -Xms512m"
    networks:
      - elk
    depends_on: #标签解决了容器的依赖、启动先后的问题
      - elasticsearch01
  kibana_test:
    image: docker.elastic.co/kibana/kibana:6.4.3
    container_name: kibana01
    volumes:
      - /elk/config/kibana.yml:/usr/share/kibana/config/kibana.yml
    ports:
      - "5601:5601"
    networks:
      - elk
    depends_on:
      - elasticsearch01
networks:
  elk:
    driver: bridge

[root@topcheer config]#

然后执行docker-compose up -d

[root@topcheer config]# docker-compose ps
     Name                    Command               State                       Ports
---------------------------------------------------------------------------------------------------------
elasticsearch01   /usr/local/bin/docker-entr ...   Up      0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp
kibana01          /usr/local/bin/kibana-docker     Up      0.0.0.0:5601->5601/tcp
logstash01        /usr/local/bin/docker-entr ...   Up      0.0.0.0:5044->5044/tcp, 0.0.0.0:9600->9600/tcp
[root@topcheer config]#

发现都很快的起起来了,docker的kibana真的很慢,但是更推荐k8s去部署,后面再写。

技术图片

 

 技术图片

 

 

以上是关于docker-compose部署ELK(亲测)的主要内容,如果未能解决你的问题,请参考以下文章

ELK部署脚本---亲测可用

Memcached实录PHP项目Yii2框架本地Docker-compose部署Memcached的坑/Yii2跨项目使用Memcached的key解决方案/亲测可用带源码建议收藏

Memcached实录PHP项目Yii2框架本地Docker-compose部署Memcached的坑/Yii2跨项目使用Memcached的key解决方案/亲测可用带源码建议收藏

docker-compose部署模板

docker-compose进行部署容器的时候,报错权限不足

docker-compose安装ELK