長沙做網(wǎng)站最好的公司win7優(yōu)化大師官方網(wǎng)站
目錄
一、在 node1 節(jié)點上操作
1.1.安裝 Kibana
1.2.設(shè)置 Kibana 的主配置文件?
1.3.啟動 Kibana 服務?
1.4.驗證 Kibana?
1.5.將 Apache 服務器的日志(訪問的、錯誤的)添加到 ES 并通過 Kibana 顯示?
1.6. 瀏覽器訪問?
二、部署Filebeat+ELK(ELFK)?
2.1.安裝 Filebeat
2.2.設(shè)置 Kibana 的主配置文件
一、在 node1 節(jié)點上操作
1.1.安裝 Kibana
[root@node1 elasticsearch-head]# cd /opt
[root@node1 opt]# rz -E #上傳軟件包 kibana-5.5.1-x86_64.rpm
[root@node1 opt]# rpm -ivh kibana-5.5.1-x86_64.rpm
1.2.設(shè)置 Kibana 的主配置文件?
[root@node1 opt]# vim /etc/kibana/kibana.yml
##2行,取消注釋,kibana服務的默認監(jiān)聽端口為5601
server.port: 5601
##7行,取消注釋,設(shè)置kibana的監(jiān)聽地址,0.0.0.0代表所有地址
server.host: "0.0.0.0"
##21行,取消注釋,設(shè)置和ES建立連接的地址和端口
elasticsearch.url: "http://192.168.190.101:9200"
##30行,取消注釋,設(shè)置在ES中添加.kibana索引
kibana.index: ".kibana"
1.3.啟動 Kibana 服務?
[root@node1 opt]# systemctl start kibana.service
[root@node1 opt]# systemctl enable kibana.service
[root@node1 opt]# netstat -natp | grep 5601
tcp 0 0 0.0.0.0:5601 0.0.0.0:* LISTEN 82765/node
1.4.驗證 Kibana?
瀏覽器訪問 http://192.168.190.101:5601
第一次登錄需要添加一個 ES 索引
點擊 create 創(chuàng)建
索引添加完成后,點擊 Discover 按鈕可查看圖表信息及日志信息
1.5.將 Apache 服務器的日志(訪問的、錯誤的)添加到 ES 并通過 Kibana 顯示?
apache 服務器
[root@apache opt]# vim /etc/logstash/conf.d/apache_log.confinput {file{path => "/etc/httpd/logs/access_log"type => "access"start_position => "beginning"}file{path => "/etc/httpd/logs/error_log"type => "error"start_position => "beginning"}
}
output {if [type] == "access" {elasticsearch {hosts => ["192.168.190.101:9200"]index => "apache_access-%{+YYYY.MM.dd}"}}if [type] == "error" {elasticsearch {hosts => ["192.168.190.101:9200"]index => "apache_error-%{+YYYY.MM.dd}"}}
}
[root@apache opt]# cd /etc/logstash/conf.d
[root@apache conf.d]# /usr/share/logstash/bin/logstash -f apache_log.conf
······
23:42:13.199 [Api Webserver] INFO logstash.agent - Successfully started Logstash API endpoint {:port=>9601}
?
1.6. 瀏覽器訪問?
瀏覽器訪問 http://192.168.190.101:9100 查看索引是否創(chuàng)建
可能你只看到了 apache-error,那是因為 access 需要訪問 httpd 頁面才能生成
瀏覽器訪問 http://192.168.190.101:5601 登錄 kibana,添加 apache_access-* 和 apache_error-* 索引,查看日志信息
?
二、部署Filebeat+ELK(ELFK)?
2.1.安裝 Filebeat
#上傳軟件包 filebeat-6.2.4-linux-x86_64.tar.gz 到/opt目錄
cd /opt
rz -E
tar zxvf filebeat-6.6.0-linux-x86_64.tar.gz
mv filebeat-6.6.0-linux-x86_64 /usr/local/filebeat
2.2.設(shè)置 Kibana 的主配置文件
[root@filebeat opt]# cd /usr/local/filebeat/
[root@filebeat filebeat]# cp filebeat.yml filebeat.yml.bak
[root@filebeat filebeat]# vim filebeat.ymlfilebeat.prospectors:
##21行,指定log類型,從日志文件中讀取消息
- type: log
##24行,開啟日志收集功能,默認為falseenabled: true
##28行,指定監(jiān)控的日志文件- /var/log/*.log
##29行,添加收集/var/log/messages- /var/log/messages
##31行,添加以下內(nèi)容,注意格式fields: service_name: filebeatlog_type: logservice_id: 192.168.190.105
#-------------------------- Elasticsearch output ------------------------------
該區(qū)域內(nèi)容全部注釋
#----------------------------- Logstash output --------------------------------
##157行,取消注釋
output.logstash:
##159行,取消注釋,指定logstash的IP和端口號hosts: ["192.168.190.101:5044"][root@filebeat filebeat]# ./filebeat -e -c filebeat.yml
#啟動filebeat,-e記錄到stderr并禁用syslog /文件輸出,-c指定配置文件
?
[root@apache ~]# cd /etc/logstash/conf.d/
[root@apache conf.d]# vim logstash.confinput {beats {port => "5044"}
}
output {elasticsearch {hosts => ["192.168.190.101:9200"]index => "%{[fields][service_name]}-%{+YYYY.MM.dd}"}stdout {codec => rubydebug}
}[root@apache conf.d]# /usr/share/logstash/bin/logstash -f apache_log.conf
??瀏覽器驗證
瀏覽器訪問,登錄 Kibana 測試,
瀏覽器訪問 http://192.168.190.101:5601 登錄 Kibana單擊“Create Index Pattern”按鈕添加索引“filebeat-*”單擊 “create” 按鈕創(chuàng)建,單擊 “Discover” 按鈕可查看圖表信息及日志信息。
?