一,安裝環境查看html
二,軟件版本選用java
jdk 1.8.0_171 elasticsearch 7.1.1 kibana 7.1.1 logstash 7.1.1
三,安裝配置node
1,安裝JDKpython
過程不詳述web
2,安裝ELKjson
官網下載安裝包bash
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-x86_64.rpm wget https://artifacts.elastic.co/downloads/kibana/kibana-7.1.1-x86_64.rpm wget https://artifacts.elastic.co/downloads/logstash/logstash-7.1.1.rpm
安裝curl
rpm -ivh elasticsearch-7.1.1-x86_64.rpm rpm -ivh kibana-7.1.1-x86_64.rpm rpm -vih logstash-7.1.1.rpm
修改elasticsearch配置文件elasticsearch
/etc/elasticsearch/elasticsearch.yml
#集羣名 cluster.name: my-es #node名 node.name: node-1 #數據目錄 path.data: /data/es-data #日誌目錄 path.logs: /var/log/elasticsearch network.host: 0.0.0.0 http.port: 9200 #集羣master須要和node名設置一致 cluster.initial_master_nodes: ["node-1"]
設置elasticsearch的jave目錄(手動安裝java需設置yum安裝的java無需設置)ui
修改配置文件
/etc/sysconfig/elasticsearch
設置java目錄
JAVA_HOME=/usr/local/jdk1.8.0_171
建立數據目錄並設置權限
mkdir -p /data/es-data chown -R elasticsearch:elasticsearch /data/es-data/
啓動elasticsearch
systemctl start elasticsearch systemctl enable elasticsearch
檢測是否啓動
[root@salt-test 7.1.1]# curl 127.0.0.1:9200 { "name" : "node-1", "cluster_name" : "my-es", "cluster_uuid" : "-5vm0JOyQP-fehWjlXal_A", "version" : { "number" : "7.1.1", "build_flavor" : "default", "build_type" : "rpm", "build_hash" : "7a013de", "build_date" : "2019-05-23T14:04:00.380842Z", "build_snapshot" : false, "lucene_version" : "8.0.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
設置kibana
修改配置文件
server.port: 5601 server.host: "0.0.0.0" server.name: "node-1" elasticsearch.hosts: ["http://192.168.1.4:9200"] kibana.index: ".kibana"
PS:7版本elasticsearch.hosts的配置在6版本里面爲elasticsearch.url 須要配置正確不然message日誌會報錯
FATAL Error: [elasticsearch.url]: definition for this key is missing
啓動
systemctl start kibana systemctl enable kibana
web頁面查看,尚未索引
安裝head
安裝head同elasticsearch6 參考 http://www.javashuo.com/article/p-xdfdlnsc-cs.html
集羣健康狀態檢查
curl -XGET 'http://192.168.1.4:9200/_cluster/health?pretty=true'
使用logstash收集日誌
標準輸入輸出
/usr/share/logstash/bin/logstash -e 'input { stdin{} } output { stdout {} }'
頁面輸入什麼則輸出什麼
以json格式輸出
輸出至ES
/usr/share/logstash/bin/logstash -e 'input { stdin{} } output { elasticsearch { hosts => ["192.168.1.4:9200"] index => "logstash-%{+YYYY.MM.dd}" } }'
啓動後標準輸出無反應
打卡head便可查看
寫一個配置文件收集系統日誌
/etc/logstash/conf.d/file.conf
input{ file{ path => ["/var/log/messages"] type => "system-log" start_position => "beginning" } } filter{ } output{ elasticsearch{ hosts => ["192.168.1.4:9200"] index => "system-log-%{+YYYY.MM}" } }
啓動放置在後臺
/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/file.conf &
當文件/var/log/messages有日誌寫入時就會寫es,在head能夠查看
把日誌添加至kiban展現
查看
elk7搭建完成與elk6搭建幾乎一致
區別爲elasticsearch配置文件須要添加配置,不然elasticsearch啓動不成功
cluster.initial_master_nodes: ["node-1"]