技术交流28群

服务热线

135-6963-3175

微信服务号

通过docker-compose搭建elk 更新时间 2022-3-11 浏览1425次

通过docker-compose搭建elk

1、首先安装docker-compose,参考 docker-comose安装

2、新建文件docker-compose.yml

version: '3'
services:
  elasticsearch:
    image: elasticsearch:6.6.2
    container_name: elasticsearch
    restart: always
    environment:
      - "cluster.name=elasticsearch"
      - "discovery.type=single-node"
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ports:
    - 9200:9200
    - 9300:9300
  kibana:
    image: docker.elastic.co/kibana/kibana:6.6.2 #6.7以前不支持中文
    container_name: kibana
    environment:
      - SERVER_NAME=kibana
      - ELASTICSEARCH_URL=http://192.168.1.7:9200   #注意此处要为ip不能为localhost;127.0.0.1未测试 
      - XPACK_MONITORING_ENABLED=true
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch
  logstash:
    image: logstash:6.6.2
    container_name: logstash
    volumes:
      - /Users/zzx/Documents/elk/logstash.conf
    depends_on:
      - elasticsearch
    links:
      - elasticsearch:es
    ports:
      - 4560:4560

文件logstash.conf:

input { #input自由发挥,可kafka filebeat等
  tcp {
    mode => "server"
    host => "0.0.0.0"
    port => 4560
    codec => json_lines
    type => "business"
  }
}
output {
  elasticsearch {
    hosts => ["localhost:9200"]
    action => "index"
    codec => json
    index => "%{type}-%{+YYYY.MM.dd}"
    template_name => "business"
  }
}

最后执行命令:

docker-compose -f docker-compose.yml up -d

1647017373935.png

等待...执行命令:

$ docker ps

1647017373319.png

status up状态

访问kibana: http://127.0.0.1:5601/

1647018541713.png

安装过程中可能出现的问题:

若kibana不能访问,出现Kibana server is not ready yet异常:

可通过命令docker logs xxx例如:docker info kibana查看日志异常等

1647017373646.png

出现该No living connections异常,发现连接es异常,可能原因localhost再容器不能访问,把kibana的(LASTICSEARCH_URL=http://192.168.1.7:9200)

es地址localhost改为本地局域网ip(127.0.0.1未测试)。

1647017373850.png

然后重新启动

docker-compose -f docker-compose.yml down

docker-compose -f docker-compose.yml up -d

然后访问kibana: http://127.0.0.1:5601/ 即可

附官方兼容性列表:

 "elastic.co/cn/support/matrix#matrix_compatibility"


注意:兼容性问题列表:

ElasticsearchKibanaX-PackBeats^*Elastic Agent^*Logstash^*ES-Hadoop (jar)APM ServerApp SearchEnterprise SearchEndpoint Security
5.0.x5.0.x5.0.x1.3.x-5.6.x
2.4.x-5.6.x5.0.x-5.6.x



5.1.x5.1.x5.1.x1.3.x-5.6.x
2.4.x-5.6.x5.0.x-5.6.x



5.2.x5.2.x5.2.x1.3.x-5.6.x
2.4.x-5.6.x5.0.x-5.6.x



5.3.x5.3.x5.3.x1.3.x-5.6.x
2.4.x-5.6.x5.0.x-5.6.x



5.4.x5.4.x5.4.x1.3.x-5.6.x
2.4.x-5.6.x5.0.x-5.6.x



5.5.x5.5.x5.5.x1.3.x-5.6.x
2.4.x-5.6.x5.0.x-5.6.x



5.6.x5.6.x5.6.x1.3.x-6.0.x
2.4.x-6.0.x5.0.x-6.0.x



6.0.x6.0.x6.0.x5.6.x-6.8.x
5.6.x-6.8.x6.0.x-6.8.x



6.1.x6.1.x6.1.x5.6.x-6.8.x
5.6.x-6.8.x6.0.x-6.8.x



6.2.x6.2.x6.2.x5.6.x-6.8.x
5.6.x-6.8.x6.0.x-6.8.x6.2.x-6.8.x


6.3.x6.3.xN/A**5.6.x-6.8.x
5.6.x-6.8.x6.0.x-6.8.x6.2.x-6.8.x


6.4.x6.4.xN/A**5.6.x-6.8.x
5.6.x-6.8.x6.0.x-6.8.x6.2.x-6.8.x


6.5.x6.5.xN/A**5.6.x-6.8.x
5.6.x-6.8.x6.0.x-6.8.x6.2.x-6.8.x


6.6.x6.6.xN/A**5.6.x-6.8.x
5.6.x-6.8.x6.0.x-6.8.x6.2.x-6.8.x


6.7.x6.7.xN/A**5.6.x-6.8.x
5.6.x-6.8.x6.0.x-6.8.x6.2.x-6.8.x


6.8.x6.8.xN/A**5.6.x-6.8.x
5.6.x-6.8.x6.0.x-6.8.x6.2.x-6.8.x


7.0.x7.0.xN/A**6.8.x-7.15.x
6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***

3.14.x - 3.18.x
7.1.x7.1.xN/A**6.8.x-7.15.x
6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***

3.14.x - 3.18.x
7.2.x7.2.xN/A**6.8.x-7.15.x
6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***7.2.x
3.14.x - 3.18.x
7.3.x7.3.xN/A**6.8.x-7.15.x
6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***7.3.x
3.14.x - 3.18.x
7.4.x7.4.xN/A**6.8.x-7.15.x
6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***7.4.x
3.14.x - 3.18.x
7.5.x7.5.xN/A**6.8.x-7.15.x
6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***7.5.x
3.14.x - 3.18.x
7.6.x7.6.xN/A**6.8.x-7.15.x
6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***7.6.x
3.14.x - 3.18.x
7.7.x7.7.xN/A**6.8.x-7.15.x
6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***N/A****7.7.x3.14.x - 3.18.x
7.8.x7.8.xN/A**6.8.x-7.15.x7.8.x6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***N/A****7.8.x3.14.x - 3.18.x
7.9.x7.9.xN/A**6.8.x-7.15.x7.9.x6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***N/A****7.9.x3.14.x - 3.19.x
7.10.x7.10.xN/A**6.8.x-7.15.x7.10.x6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***N/A****7.10.x3.14.x - 3.20.x
7.11.x7.11.xN/A**6.8.x-7.15.x7.11.x6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***N/A****7.11.x3.14.x - 3.21.x
7.12.x7.12.xN/A**6.8.x-7.15.x7.12.x6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***N/A****7.12.x3.14.x - 3.22.x
7.13.x7.13.xN/A**6.8.x-7.15.x7.13.x6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***N/A****7.13.x3.14.x - 3.23.x
7.14.x7.14.xN/A**6.8.x-7.15.x7.14.x6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***N/A****7.14.x3.14.x - 3.24.x
7.15.x7.15.xN/A**6.8.x-7.15.x7.15.x6.8.x-7.15.x7.0.x-7.15.x7.0.x-7.15.x***N/A****7.15.x3.14.x - 3.24.x