本文將介紹若是使用logstash,elasticsearch,kibana搭建一個日誌分析系統。Logstash支持的日誌類型很是的普遍,支持nginx,postfix.windows系統日誌,java日誌以及mysql慢查詢日誌,Docker日誌等,並帶有強大的過濾器功能,還能夠輸出到elasticsearch,nagios,mail等,功能至關的強大,在咱們要部署的日誌分析系統中logstash用來收集各類日誌,而後推送給elasticsearch,kibana負責經過web接口最終展現出來。java
環境介紹:mysql
操做系統版本:centos6.6 64bitlinux
Logstash版本: logstash-2.0.0.tar.gzios
Elasticsearch版本:elasticsearch-2.1.0.tar.gznginx
Kibana版本:Kibana 4.2.1web
Java版本:1.8.0_45sql
一:軟件下載windows
# wget https://download.elastic.co/logstash/logstash/logstash-2.0.0.tar.gz # wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.1.0/elasticsearch-2.1.0.tar.gz # wget https://download.elastic.co/kibana/kibana/kibana-4.2.1-linux-x64.tar.gz
二:軟件安裝
centos
1:安裝java環境ruby
# java -version java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
2:解壓軟件包
# tar -zxvpf logstash-2.0.0.tar.gz # mv logstash-2.0.0 /usr/local/logstash # tar -zxvpf elasticsearch-2.1.0.tar.gz # mv elasticsearch /usr/local/elasticsearch # tar -zxvpf kibana-4.2.1-linux-x64.tar.gz # mv kibana-4.2.1 /usr/local/kibana
3:啓動elasticsearch,kibana
這裏能夠根據本身的實際需求來修改yml配置文件
# useradd yang # chown -R yang.yang /usr/local/elasticsearch/ # nohup su - yang -c /usr/local/elasticsearch/bin/elasticsearch & # /usr/local/kibana/bin/kibana
4:配置logstash,運行測試
# logstash -e 'input{stdin{}}output{stdout{codec=>rubydebug}}'
配置文件方式運行logstash測試, 將數據推送到elasticsearch
# cat /usr/local/logstash/etc/logstash.conf input { stdin { } } output { stdout { codec => rubydebug {} } elasticsearch { hosts => "192.168.115.5" } } # /usr/local/logstash/bin/logstash -f /usr/local/logstash/etc/logstach.conf
http://192.168.115.5:9200/_search?q=hello
Kibana上配置相應的索引前綴