目錄
?
一、filebeat?
二、ELFK
1.原理簡(jiǎn)介
2.在ELK基礎(chǔ)上部署filebeat
?
一、filebeat?
????????Filebeat,輕量級(jí)的開(kāi)源日志文件數(shù)據(jù)搜集器。通常在需要采集數(shù)據(jù)的客戶端安裝 Filebeat,并指定目錄與日志格式,F(xiàn)ilebeat 就能快速收集數(shù)據(jù),并發(fā)送給 logstash 進(jìn)行解析,或是直接發(fā)給 Elasticsearch 存儲(chǔ),性能上相比運(yùn)行于 JVM 上的 logstash 優(yōu)勢(shì)明顯,是對(duì)它的替代。常應(yīng)用于 EFLK 架構(gòu)當(dāng)中。
filebeat 結(jié)合 logstash 帶來(lái)好處
1)通過(guò) Logstash 具有基于磁盤(pán)的自適應(yīng)緩沖系統(tǒng),該系統(tǒng)將吸收傳入的吞吐量,從而減輕 Elasticsearch 持續(xù)寫(xiě)入數(shù)據(jù)的壓力
2)從其他數(shù)據(jù)源(例如數(shù)據(jù)庫(kù),S3對(duì)象存儲(chǔ)或消息傳遞隊(duì)列)中提取
3)將數(shù)據(jù)發(fā)送到多個(gè)目的地,例如S3,HDFS(Hadoop分布式文件系統(tǒng))或?qū)懭胛募?/p>
4)使用條件數(shù)據(jù)流邏輯組成更復(fù)雜的處理管道
二、ELFK
1.原理簡(jiǎn)介
? ? ? ? 在ELK中,Logstash 負(fù)責(zé)收集日志,將日志格式化并輸出到 Elasticsearch 群集中;Elasticsearch 對(duì)格式化后的數(shù)據(jù)進(jìn)行索引和存儲(chǔ);Kibana 從 ES 群集中查詢數(shù)據(jù)生成圖表,并進(jìn)行前端數(shù)據(jù)的展示。
? ? ? ? 而在ELFK中,filebeat替代logstash收集日志,而logstash負(fù)責(zé)格式化日志和輸出到es集群。
2.在ELK基礎(chǔ)上部署filebeat
nginx服務(wù)器部署filebeat:192.168.116.40
logstash+kibana服務(wù)器:192.168.116.50
es節(jié)點(diǎn)1:192.168.116.60
es節(jié)點(diǎn)2:192.168.116.70
關(guān)閉防火墻和selinux
下載nginx,添加測(cè)試頁(yè)面
#配置nginx官方源
cd /etc/yum.repos.d/
vim nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
#下載并啟動(dòng)
yum -y install nginx
systemctl enable --now nginx
#添加測(cè)試頁(yè)面
cd /usr/share/nginx/html/
echo '<h1>this is nginxlog test1 webpage</h1>' > test1.html
echo '<h1>this is nginxlog test2 webpage</h1>' > test2.html
準(zhǔn)備filebeat安裝包,解壓安裝
tar xf filebeat-6.7.2-linux-x86_64.tar.gz
mv filebeat-6.7.2-linux-x86_64 /usr/local/filebeat
修改filebeat配置文件 /usr/local/filebeat/filebeat.yml
啟動(dòng)filebeat
nohup ./filebeat -e -c filebeat.yml? ? ? ? nohup后臺(tái)啟動(dòng)(不會(huì)因?yàn)橥顺鼋K端而終端)
? ? ? ? ? ? ? ? ? ? ? ? ? -e? ? ? ? 同時(shí)輸出到屏幕(便于實(shí)驗(yàn)),也可以使用重定向到文件中
? ? ? ? ? ? ? ? ? ? ? ? ? -c? ? ? ? 指定配置文件
修改logstash配置文件
啟動(dòng)logstash
測(cè)試索引收集日志
但是此索引包含了nginx的access.log和error.log,我們可以在配置文件中添加條件判斷分割日志,然后重啟服務(wù)測(cè)試
在客戶端訪問(wèn)nginx測(cè)試頁(yè)面,然后刷新es,出現(xiàn)了分割的索引?
在kibana中創(chuàng)建對(duì)應(yīng)索引
之后就可以查看了文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-635605.html
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-635605.html
到了這里,關(guān)于ELFK——ELK結(jié)合filebeat日志分析系統(tǒng)(2)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!