前言
Elasticsearch + Logstash + Kibana(ELK)是一套開源的日志管理方案,分析網站的訪問情況時我們一般會借助 Google / 百度 / CNZZ 等方式嵌入 JS 做資料統計,但是當網站訪問例外或者被攻擊時我們需要在后臺分析如 Nginx 的具體日志,而 Nginx 日志分割 / GoAccess/Awstats 都是相對簡單的單節點解決方案,針對分布式集群或者資料量級較大時會顯得心有余而力不足,而 ELK 的出現可以使我們從容面對新的挑戰,
Logstash:負責日志的收集,處理和儲存
Elasticsearch:負責日志檢索和分析
Kibana:負責日志的可視化
ELK(Elasticsearch + Logstash + Kibana)

搭建程序
環境準備
下載RPM包
P.S: 由于ES的官網的速度對我們國內很不友好,我已經將安裝包傳至國內網站上,直接下載即可
kibana-7.8.0-x86_64.rpm
elasticsearch-7.8.0-x86_64.rpm
logstash-7.8.0.rpm
windows:先下載在主機上,通過軟體上傳至服務器端
Linux:通過SCP命令上傳至服務器端

安裝Elasticsearch
yum -y install elasticsearch-7.8.0-x86_64.rpm
sed -i '17s/#cluster.name: my-application/cluster.name: elk/' /etc/elasticsearch/elasticsearch.yml
sed -i '23s/#node.name: node-1/node.name: node-1/' /etc/elasticsearch/elasticsearch.yml
sed -i '55s/#network.host: 192.168.0.1/network.host: 127.0.0.1/' /etc/elasticsearch/elasticsearch.yml
systemctl daemon-reload
systemctl enable elasticsearch.service
systemctl start elasticsearch
安裝Kibana
yum -y install kibana-7.8.0-x86_64.rpm
sed -i '7s/#server.host: "localhost"/server.host: "0.0.0.0"/' /etc/kibana/kibana.yml
sed -i '28s/#elasticsearch.hosts: .*/elasticsearch.hosts: ["http:\/\/127.0.0.1:9200"]/' /etc/kibana/kibana.yml
#清空防火墻規則
iptables -F
service iptables save
systemctl enable kibana
systemctl start kibana
安裝Logstash
yum -y install logstash-7.8.0.rpm
驗證
訪問 http://服務器地址:5601/

至此,ELK(Elasticsearch + Logstash + Kibana) 搭建教程結束
- 如果時阿里云ECS需要添加安全組規則放行5601埠
寫在最后
如果檔案對你有幫助的話,留個贊再走吧 ,你的點擊是我的最大動力,
我是鍵盤俠,現實中我唯唯諾諾,網路上我重拳出擊,關注我,持續更新Linux干貨教程,
更多鍵盤俠Linux系列教程:鏈接地址
更多Linux干貨教程請掃:(回復 干貨)

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/49293.html
標籤:Linux
