服務器環境html
elk 組件前端
serverjava
java 環境配置
logstash安裝配置
elasticsearch安裝配置
kibana 安裝配置
redis 安裝
<p></p>linux
java 下載 https://www.java.com/zh_CN/download/manual.jspredis
weget http://sdlc-esd.oracle.com/ESD6/JSCDL/jdk/8u111-b14/jre-8u111-linux-x64.tar.gz?GroupName=JSC&FilePath=/ESD6/JSCDL/jdk/8u111-b14/jre-8u111-linux-x64.tar.gz&BHost=javadl.sun.com&File=jre-8u111-linux-x64.tar.gz&AuthParam=1477997592_8023dba3df857730418d4bd15a12ec0b&ext=.gz` sudo mkdir -p /usr/local/java/ sudo tar -zxvf jre-8u111-linux-x64.tar.gz -C /usr/local/java/ sudo cp /etc/environment /etc/environment.bak sudo vim /etc/environment
修改PATH參數,添加java路徑 :/usr/local/java/jre1.8.0_111/binjson
java -version
驗證 java 環境
ubuntu@ubuntu:~$ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)ubuntu
官網地址:https://www.elastic.co/products</p>
全部組件下載5.0.0版本,tar.gz 壓縮包vim
sudo tar -zxvf logstash-5.0.0.tar.gz -C /usr/local/ sudo chown -R ubuntu.ubuntu /usr/local/logstash-5.0.0/
sudo tar -zxvf elasticsearch-5.0.0.tar.gz -C /usr/local/ sudo chown -R ubuntu.ubuntu /usr/local/elasticsearch-5.0.0/
tar -zxvf kibana-5.0.0-linux-x86_64.tar.gz -C /usr/local/ sudo chown -R ubuntu.ubuntu /usr/local/kibana-5.0.0-linux-x86_64/ vim /usr/local/kibana-5.0.0-linux-x86_64/config/kibana.yml
找到server.hsot 參數 做以下修改緩存
#server.host: "localhost" server.host: "0.0.0.0"
sudo apt-get install redis-server
shipper配置文件
index配置文件
cd /usr/local/logstash-5.0.0/ mkdir conf cd conf vim ./shipper.conf
添加如下配置ruby
input { udp { host => "0.0.0.0" port => "8899" } } output { stdout { } redis { host => "127.0.0.1" port => "6379" data_type => "channel" key => "yourkeyname" } }
cd /usr/local/logstash-5.0.0/conf vim index.conf
添加配置
input { redis { host => "127.0.0.1" data_type => "channel" key => "yourkeyname" } } filter { json { source => "message" } } output { stdout { } elasticsearch { hosts => ["127.0.0.1:9200"] index => "testlog" codec => "json" } }
啓動組件
經過supervisor啓動
在5.5.0版本中 若是啓動多個logstash 實例 會有錯誤拋出
解決方案是 /path/to/logstash -f /path/to/conf --path.data ./newdatadir
在執行腳本加上 每一個instance的獨立data 文件
/usr/local/elasticsearch-5.0.0/bin/elasticsearch /usr/local/kibana-5.0.0-linux-x86_64/bin/kibana /usr/local/logstash-5.0.0/bin/logstash -f /usr/local/logstash-5.0.0/conf/index.conf /usr/local/logstash-5.0.0/bin/logstash -f /usr/local/logstash-5.0.0/conf/shipper.conf
正式環境不推薦這種啓動
sudo apt-get install supervisor -y sudo service supervisor start sudo vim /etc/supervisor/conf.d/elk.conf
添加如下配置
[program:es] user=ubuntu environment=LS_HEAP_SIZE=5000m directory=/usr/local/elasticsearch-5.0.0/ command=/usr/local/elasticsearch-5.0.0/bin/elasticsearch [program:kibana] user=ubuntu environment=LS_HEAP_SIZE=5000m directory=/usr/local/kibana-5.0.0-linux-x86_64/ command=/usr/local/kibana-5.0.0-linux-x86_64/bin/kibana [program:ls-shipper] user=ubuntu environment=LS_HEAP_SIZE=5000m directory=/usr/local/logstash-5.0.0/ command=/usr/local/logstash-5.0.0/bin/logstash -f /usr/local/logstash-5.0.0/conf/shipper.conf [program:ls-index] user=ubuntu environment=LS_HEAP_SIZE=5000m directory=/usr/local/logstash-5.0.0/ command=/usr/local/logstash-5.0.0/bin/logstash -f /usr/local/logstash-5.0.0/conf/index.conf
啓動supervisor
sudo supervisorctl start all
執行後會有報錯
ls-shipper: ERROR (abnormal termination)
ls-index: ERROR (abnormal termination)
es: ERROR (abnormal termination)
解決辦法:sudo ln -sv /usr/local/java/jre1.8.0_111/bin/java /usr/bin/java
# 配置示例 [Unit] Description=Elk Elasticsearch-5.0.0 [Service] WorkingDirectory=/usr/local/elasticsearch-5.0.0/ ExecStart=/usr/local/elasticsearch-5.0.0/bin/elasticsearch Restart=always RestartSec=10 SyslogIdentifier=Elasticsearch User=ubuntu [Install] WantedBy=multi-user.target
測試數據發送
index 管理
圖表管理
下載udp客戶端工具,向logstash 發送測試數據
{ "class":"ERROR", "logger_name":"testlogger", "application":"udpsender", "message":"high Hkaos three", "addUser":"tester", "addUserName":"testName", "objName":"objName", "objId":"objId", "hash":-1, "method":"Main", "timestamp":"0001-01-01T00:00:00" }
在上文 logstash index配置文件中的output 配置了index => testlog
訪問 http://yourserverip:5601/
在Management --> Index Patterns --> add new 添加testlog
若是沒有識別出來的話說明 logstash 和 elasticsearch 的通信異常,或者啓動有問題,查看日誌進行排查
到此本次安裝基本完成,kibana 頁面上的數據管理不難理解,本文沒有進行說明
補充:
es 插件安裝
es 5.0 不支持 插件安裝 (除了官方提供的插件)
elasticsearch-plugs install -h
安裝方式參考下面博客
http://blog.csdn.net/amds123/...