Elasticsearch是个开源分布式搜索引擎,它的特色有:分布式,零配置,自动发现,索引自动分片,索引副本机制,restful风格接口,多数据源,自动搜索负载等。html
Logstash是一个彻底开源的工具,他能够对你的日志进行收集、过滤,并将其存储供之后使用(如,搜索)。linux
Kibana 也是一个开源和免费的工具,它Kibana能够为 Logstash 和 ElasticSearch 提供的日志分析友好的 Web 界面,能够帮助您汇总、分析和搜索重要数据日志。vim
elk下载地址:www.elastic.co/downloads/windows
建议在 linux上运行,elk在windows上支持得很差,另外须要jdk1.8 的支持,须要提早安装好jdk.restful
下载完以后: 安装,以logstash为栗子:架构
1
2
3
4
5
6
7
|
cd /usr/local/
mkdir logstash
tar -zxvf logstash-
5.3
.
2
.tar.gz
mv logstash-
5.3
.
2
/usr/local/logstash
|
打开Elasticsearch的配置文件:app
1
|
vim config/elasticsearch.yml
|
修改配置:elasticsearch
1
2
|
network.host=localhost
network.port=
9200
|
它默认就是这个配置,没有特殊要求,在本地不须要修改。分布式
启动Elasticsearch微服务
1
|
./bin/elasticsearch
|
启动成功,访问localhost:9200,网页显示:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
{
"name"
:
"56IrTCM"
,
"cluster_name"
:
"elasticsearch"
,
"cluster_uuid"
:
"e4ja7vS2TIKI1BsggEAa6Q"
,
"version"
: {
"number"
:
"5.2.2"
,
"build_hash"
:
"f9d9b74"
,
"build_date"
:
"2017-02-24T17:26:45.835Z"
,
"build_snapshot"
:
false
,
"lucene_version"
:
"6.4.1"
},
"tagline"
:
"You Know, for Search"
}
|
在 logstash的主目录下:
1
|
vim config/log4j_to_es.conf
|
修改 log4j_to_es.conf 以下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
input {
log4j {
mode =>
"server"
host =>
"localhost"
port =>
4560
}
}
filter {
#Only matched data are send to output.
}
output {
elasticsearch {
action =>
"index"
#The operation on ES
hosts =>
"localhost:9200"
#ElasticSearch host, can be array.
index =>
"applog"
#The index to write data to.
}
}
|
修改完配置后启动:
1
|
./bin/logstash -f config/log4j_to_es.conf
|
架构代码以下 :
Spring Cloud大型企业分布式微服务云架构源码请加企鹅求求:一七九一七四三三八零