BlueXIII's Blog

热爱技术,持续学习

0%

ELK分布式日志平台初步配置

简介

ELK = Elasticsearch + Logstash + Kibana ,是一套非常流行的分布式日志采集、处理、汇总及展示工具。

  • Logstash - 日志采集、过滤,并转发给Elasticsearch
  • Elasticsearch - 搜索引擎,存储、索引、分析日志
  • Kibana - WEB界面,查询并展示Elasticsearch的数据

本文主要介绍ELK日志平台初步搭建及配置。

Elastic官网

https://www.elastic.co/start

安装Elasticsearch

1
2
3
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

1
2
3
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

1
2
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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的用户名及密码

运行

1
2
3
bin/elasticsearch
bin/kibana
bin/logstash -f logstash.conf

登录Kibana控制台

http://localhost:5601

初始用户名密码: elastic/changeme