docker-compose部署ELK(亲测)

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

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

kibana.yml

[[email protected] 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

[[email protected] 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

[[email protected] 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

[[email protected] 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去部署,后面再写。

 

 

 

 

猜你喜欢

转载自www.cnblogs.com/dalianpai/p/11986481.html