EIK是什么
E 指的是 ElasticSearch 搜索引擎 I 指的是Logstash 数据收集引擎 K 指的是 kibana 日志分析web界面展示,可以汇总、分析和搜索重要数据日志。
开始搭建
下载镜像
docker pull elasticsearch:6.4.0
docker pull logstash:6.4.0
docker pull kibana:6.4.0
创建文件夹
mkdir /home/es/logstash
mkdir /home/es/elasticsearch/data
chmod 777 /home/es/elasticsearch/data
创建文件
创建logstash-springboot.conf
input {
tcp {
mode => "server"
host => "0.0.0.0"
port => 4560
codec => json_lines
}
}
output {
elasticsearch {
hosts => "es:9200"
index => "springboot-logstash-%{+YYYY.MM.dd}"
}
}
创建docker-compose.yml
version: '3'
services:
elasticsearch:
image: elasticsearch:6.4.0
container_name: elasticsearch
environment:
- "cluster.name=elasticsearch"
- "discovery.type=single-node"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
volumes:
- /home/es/elasticsearch/plugins:/usr/share/elasticsearch/plugins
- /home/es/elasticsearch/data:/usr/share/elasticsearch/data
ports:
- 9200:9200
- 9300:9300
kibana:
image: kibana:6.4.0
container_name: kibana
links:
- elasticsearch:es
depends_on:
- elasticsearch
environment:
- "elasticsearch.hosts=http://es:9200"
ports:
- 5601:5601
logstash:
image: logstash:6.4.0
container_name: logstash
volumes:
- /home/es/logstash/logstash-springboot.conf:/usr/share/logstash/pipeline/logstash.conf
depends_on:
- elasticsearch
links:
- elasticsearch:es
ports:
- 4560:4560
启动脚本中的容器
docker-compose up -d (如果不存在就安装 pip install docker-compose)
安装elasticsearch插件
安装ik分词器
docker exec -it elasticsearch /bin/bash
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.0/elasticsearch-analysis-ik-6.4.0.zip
exit
docker restart elasticsearch
安装logstash插件
安装json相关插件
docker exec -it logstash /bin/bash
cd /bin/
logstash-plugin install logstash-codec-json_lines
exit
docker restart logstash
查看容器启动情况
docker ps
查询某个容器日志
docker logs -f 9b681ca30bd1(你的容器id)
进入某个容器
docker exec -it 容器名称 /bin/bash
登陆kibana
http://你的ip:5601/
在搭建过程中 如果遇到什么问题,可留言进行说明。
|