1. 程式人生 > >ELK安裝與使用

ELK安裝與使用

mac環境安裝

brew方式

安裝es 和 kibana

//安裝
$ brew update
$ brew install elasticsearch
$ brew install kibana

//檢視版本
elasticsearch --version
kibana --version

//可以分別看到兩個軟體的一些安裝資訊,比如安裝路徑和配置檔案的路徑等
$ brew info elasticsearch
$ brew info kibana

//啟動
$ brew services start elasticsearch / 或者直接elasticsearch
$ brew services stop elasticsearch
$ 
brew services start kibana 或者直接kibana $ brew services stop kibana $ brew services restart elasticsearch $ brew services restart kibana //驗證 jps localhost:9200 //es localhost:5601 //kibana

安裝的路徑

elasticsearch:  /usr/local/Cellar/elasticsearch/5.5.0
Data:    /usr/local/var/elasticsearch/elasticsearch_xuchen/
Logs:    /usr/local
/var/log/elasticsearch/elasticsearch_xuchen.log Plugins: /usr/local/opt/elasticsearch/libexec/plugins/ Config: /usr/local/etc/elasticsearch/ plugin script: /usr/local/opt/elasticsearch/libexec/bin/elasticsearch-plugin

插入文件資料

curl -XPUT "http://localhost:9200/movies/movie/1" -d'
{
    "title": "The Godfather",
    "director"
: "Francis Ford Coppola", "year": 1972 }' 或者 curl -H "Content-Type: application/json" -XPUT "http://localhost:9200/movies/movie/1" -d' [email protected] { "title": "The Godfather", "director": "Francis Ford Coppola", "year": 1972 }'

安裝logstash

brew install logstash
$ logstash --version

logstash
logstash -e ""//通過命令列,進入到logstash/bin目錄,執行下面的命令

下載解壓包方式

windows環境安裝

logstash使用

輸出到es

配置檔案/usr/local/etc/logstash/config_command_to_es.conf

input { stdin { } }
output {
  elasticsearch { hosts => ["localhost:9200"] }
  stdout { codec => rubydebug }
}

從redis輸出到es

input {
redis {
data_type => “list”
type => “redis-input”
key => “logstash:redis”
host => “192.168.212.37”
port => 6379
threads => 5
codec => “json”
}
}
output {
elasticsearch {
hosts => “192.168.212.37:9201”
index => “logstash-test”
}
stdout {
codec => rubydebug {}
}
}