天天看點

ELK( ElasticSearch+ Logstash+ Kibana)分布式日志系統部署文檔

開始在公司實施的小應用,慢慢完善之~~~~~~~~文檔制作 了好作運維同僚之間的前期普及。。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

軟體下載下傳位址:

<a href="https://www.elastic.co/downloads">https://www.elastic.co/downloads</a>

在實際部署中,根據伺服器的性能配置,elk可部署在同一個機器上,也可以分别安裝在不同的機器上,隻要能保證網絡連通。但建議elasticsearch和kibana部署在同一個機器上,這樣可以加快檢索速度。

shipper: 分布式部署在各應用伺服器,收集并轉發日志。

broker:将日志集中收集、排隊并轉發。

indexer:收集和轉發資料至elasticsearch。在elasticsearch建立索引并存儲日志資料。

web interface:基于nginx的kibana3 http通路接口,提供ui搜尋elasticsearch的資料。

一,elasticsearch

1,解壓elasticsearch-1.4.4.tar.gz

2,啟動指令bin/elasticsearch

二,logstash

1,解壓logstash-1.4.2.tar.gz

2.a 作為indexer檔案的logstash.conf(樣例,從redis裡擷取資料)

input {

redis {

host =&gt; '10.x.x.x'(redis的位址)

data_type =&gt; 'list'

port =&gt; "6379"

key =&gt; 'logstash:redis'

type =&gt; 'redis-input'

}

output {

elasticsearch {

host =&gt; "10.x.x.x"(elasticsearch的位址)

2.b 作為shipper的logstash.conf配置(樣例,将日志注入redis,可作過濾)

file {

type =&gt; "app_ip_java_debug"

path =&gt; "/var/logs/tomcat/*.out"

#filter {

# grep {

# match =&gt; [ "@message", "freshclam" ]

# }

host =&gt; '10.x.x.x'(送出到redis的位址)

3,啟動指令bin/logstash agent -f logstash.conf

三,redis

1, 下載下傳redis-2.8.18.tar.gz

2, 安裝參考http://blog.csdn.net/testcs_dn/article/details/39756477

四,kibana

1, 解壓kibana-4.0.0-linux-x64.tar.gz

2, 編輯conf/kibana.yml檔案(将elasticseach服務位址定位)

elasticsearch_url: "http://localhost:9200"

3, 啟動指令bin/kibana

五,附錄(網上其它類似配置和搜尋條件)

以nginx通路日志為例,配置如下:

1)shipper.conf

type =&gt; "nginx"

path =&gt; [ "/nginx/path/logs/access.log" ]

start_position =&gt; "beginning"

sincedb_path =&gt; "/some/place/sincedb_nginx"

filter {

grok {

match =&gt; [ "message", "%{ip:client} (%{user:indent}|-) (%{user:auth}|-) \[%{httpdate:local_time}\] \"%{word:method} (?&lt;request_url&gt;%{uripath})(?&lt;request_params&gt;%{uriparam}) http/%{number:protocol}\" %{number:status} %{number:bytes_sent} %{qs:http_referer} %{qs:user_agent}" ]

date {

locale =&gt; "en"

match =&gt; [ "local_time", "dd/mmm/yyyy:hh:mm:ss z" ]

timezone =&gt; "asia/shanghai"

host =&gt; "192.168.1.130"

port =&gt; 6379

data_type =&gt; "list"

key =&gt; "nginx"

2) indexer.conf

常用的有以下幾種

1)邏輯查詢

2)範圍查詢

3)子查詢

4)通配符

5)保留字元轉義

繼續閱讀