1. 程式人生 > >ELK安裝文檔 + 索引可視化

ELK安裝文檔 + 索引可視化

ELK elasticsearch elk安裝 elk部署 Linux

++elk官網:www.elastic.co++

filebeat: 搜集日誌
Elasticsearch: 存儲日誌
Kibana: 查尋和可視化日誌;

elasticsearch部署

elasticsearch下載地址:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz

==================================================================

elasticsearch的安裝,它依賴於java的環境,所以得先配置java環境

tar xf jdk-1.8.0_211.tar.gz -C /usr/local/       ##給JDK解壓,指定路徑為/usr/local下

vim /etc/profile:    ##配置環境變量
export JAVA_HOME=/usr/local/jdk1.8.0_121 
export PATH=$JAVA_HOME:$JAVA_HOME/bin 
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

安裝elasticsearch :

tar xf elasticsearch-5.2.2.tar.gz -C /usr/local/ ##指定解壓的路徑 
cd /usr/local/elasticsearch-5.2.2 
chown -R alex.alex /usr/local/elasticsearch-5.2.2 
su - alex ./bin/elasticsearch -d    ##elasticsearch不能root啟動 

修改elasticsearch的配置文件:

cat /usr/local/elasticsearch-5.2.2/config/elasticsearch.yml 
path.data:/data/elasticsearch/data 
path.logs:/data/elasticsearch/logs 
network.host:0.0.0.0 
http.cors.enabled:true 
http.cors.allow-origin:"*"

elasticsearch對內核系統參數有規定,所以設置內核參數:
==ulimit -n 查看當前環境的參數. 如果大於或者等於65536 就可以了==
#! 或者修改為: (elasticsearch啟動不能用root 所以其他用戶的環境也要大於65536)

cat /etc/security/limits.conf

soft    nproc   65536
hard    nproc   65536
soft    nofile  65536
hard    nofile  65536

cat /etc/sysctl.conf 
vm.max_map_count= 262144

sysctl -p ###查看參數

修改ulimit遇到的問題. 以上值都修改了,也重啟了,就是不生效.
==! {查看/etc/Profile 腳本裏面有個 " ulimit -n " 把他的值修改為65536}==
其次要註意的就是權限問題. 最好把elasticsearch整個目錄設置為啟動的普通用戶為用戶主目錄.
用alex 啟動elasticsearch服務

su - alex 
./usr/local/elasticsearch-5.2.2/bin/elasticsearch & netstart -antupl |grep :9200 curl localhost:9200

filebeat安裝

filebeat下載地址:

wget https://www.elastic.co/downloads/beats/filebeat

配置文件是filebeat.yml

vim filebeat.yml 
host ["serverIP:9200"] 
index "myIP-%{+yyyy.MM.dd}"

** filebeat 可以指定多配置啟動.

kibana 安裝文檔:

wge https://artifacts.elastic.co/downloads/kibana/kibana-6.0.1-linux-x86_64.tar.gz
tar xf kibana-6.0.1-linux-x86_64.tar.gz

配置文件修改如下:

cat kibana.yml |grep -v "#" |grep -v "^$"
server.port: 5000
server.host: "0.0.0.0"
elasticsearch.url: "http://116.62.167.119:9200"

遇到的問題

如果elasticsearch和kibana 是商業版的有賬號和密碼
filebeat 配置文件中配置如下:

filebeat.prospectors:
- input_type: log
  paths:
    - /data/app_logs/shoot-pay-uat/*.log
output.elasticsearch:
  hosts: ["es-cn-0pp0gy1kt000a0iqg.elasticsearch.aliyuncs.com:9200"]
  username: "elastic"
  password: "Misadmin123"
  index: "shoot-pay-uat-%{+yyyy.MM.dd}"

cerebro

下載地址:
https://github.com/KELiON/cerebro/releases #選擇合適版本

解壓:
tar xf cerebro-xxx
配置文件為==config/application== 配置如下

secret = "ki:s:[[@=Ag?QI`W2jMwkY:eqvrJ]JqoJyi2axj3ZvOv^/KavOT4ViJSv?6YY4[N"
basePath = "/"
rest.history.size = 50 // defaults to 50 if not specified
data.path = "./cerebro.db"
auth = {
}
hosts = [
  {
    host = "http://118.31.188.238:9200"
    name = "elasticsearch"
  }
]

#

啟動腳本在/bin/cerebro && 啟動:

nohup ./usr/local/cerebro/bin/cerebro &

#
用瀏覽器訪問:
cerebro_server-ip:9000 #9000為默認端口

ELK安裝文檔 + 索引可視化