简介
ELK = Elasticsearch + Logstash + Kibana ,是一套非常流行的分布式日志采集、处理、汇总及展示工具。
- Logstash - 日志采集、过滤,并转发给Elasticsearch
- Elasticsearch - 搜索引擎,存储、索引、分析日志
- Kibana - WEB界面,查询并展示Elasticsearch的数据
本文主要介绍ELK日志平台初步搭建及配置。
Elastic官网
安装Elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.0.tar.gz
tar -zxvf elasticsearch-5.6.0.tar.gz
bin/elasticsearch-plugin install x-pack # 安装XPack(可选)
网络不稳定时,可能需要挂$$代理+Proxifier
安装Kibana
wget https://artifacts.elastic.co/downloads/kibana/kibana-5.6.0-darwin-x86_64.tar.gz
tar -zxvf kibana-5.6.0-darwin-x86_64.tar.gz
bin/kibana-plugin install x-pack # 安装XPack(可选)
安装Logstash
wget https://artifacts.elastic.co/downloads/logstash/logstash-5.6.1.tar.gz
tar -zxvf logstash-5.6.1.tar.gz
配置Logstash
vi logstash.conf
input {
file {
path => "/opt/logs/busi/playground.log"
ignore_older => 0
sincedb_path => "/dev/null"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
user => "elastic"
password => "changeme"
}
stdout { codec => rubydebug }
}
注意如果安装了XPack,在output中需要配置elasticsearch的用户名及密码
运行
bin/elasticsearch
bin/kibana
bin/logstash -f logstash.conf
登录Kibana控制台
初始用户名密码: elastic/changeme