提高安全性
創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)與策劃設(shè)計(jì),樂(lè)東黎族網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)10余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:樂(lè)東黎族等地區(qū)。樂(lè)東黎族做網(wǎng)站價(jià)格咨詢:18982081108
集中存放日志
缺陷:對(duì)日志的分析困難
Elasticsearch:存儲(chǔ),索引池
Logstash:日志收集器
Kibana:數(shù)據(jù)可視化
1,將日志進(jìn)行集中化管理
2,將日志格式化(Logstash)并輸出到Elasticsearch
3,對(duì)格式化后的數(shù)據(jù)進(jìn)行索引和存儲(chǔ)(Elasticsearch)
4,前端數(shù)據(jù)的展示(Kibana)
提供了一個(gè)分布式多用戶能力的全文搜索引擎
接近實(shí)時(shí)
集群
節(jié)點(diǎn)
索引:索引(庫(kù))-->類型(表)-->文檔(記錄)
分片和副本
一款強(qiáng)大的數(shù)據(jù)處理工具,可以實(shí)現(xiàn)數(shù)據(jù)傳輸、格式處理、格式化輸出
數(shù)據(jù)輸入、數(shù)據(jù)加工(如過(guò)濾,改寫等)以及數(shù)據(jù)輸出
Shipper
Indexer
Broker
Search and Storage
Web Interface
一個(gè)針對(duì)Elasticsearch的開(kāi)源分析及可視化平臺(tái)
搜索、查看存儲(chǔ)在Elasticsearch索引中的數(shù)據(jù)
通過(guò)各種圖表進(jìn)行高級(jí)數(shù)據(jù)分析及展示
Elasticsearch無(wú)縫之集成
整合數(shù)據(jù),復(fù)雜數(shù)據(jù)分析
讓更多團(tuán)隊(duì)成員受益
接口靈活,分享更容易
配置簡(jiǎn)單,可視化多數(shù)據(jù)源
簡(jiǎn)單數(shù)據(jù)導(dǎo)出
[root@node1 ~]# vim /etc/hosts ##配置解析名
192.168.52.133 node1
192.168.52.134 node2
[root@node1 ~]# systemctl stop firewalld.service ##關(guān)閉防火墻
[root@node1 ~]# setenforce 0 ##關(guān)閉增強(qiáng)型安全功能
[root@node1 ~]# java -version ##查看是否支持Java
[root@node1 ~]# mount.cifs //192.168.100.100/tools /mnt/tools/ ##掛載
Password for root@//192.168.100.100/tools:
[root@node1 ~]# cd /mnt/tools/elk/
[root@node1 elk]# rpm -ivh elasticsearch-5.5.0.rpm ##安裝
警告:elasticsearch-5.5.0.rpm: 頭V4 RSA/SHA512 Signature, 密鑰 ID d88e42b4: NOKEY
準(zhǔn)備中... ################################# [100%]
Creating elasticsearch group... OK
Creating elasticsearch user... OK
正在升級(jí)/安裝...
1:elasticsearch-0:5.5.0-1 ################################# [100%]
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
sudo systemctl start elasticsearch.service
[root@node1 elk]# systemctl daemon-reload ##重載守護(hù)進(jìn)程
[root@node1 elk]# systemctl enable elasticsearch.service ##開(kāi)機(jī)自啟
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.
[root@node1 elk]# cd /etc/elasticsearch/
[root@node1 elasticsearch]# cp elasticsearch.yml elasticsearch.yml.bak ##備份
[root@node1 elasticsearch]# vim elasticsearch.yml ##修改配置文件
cluster.name: my-elk-cluster ##集群名
node.name: node1 ##節(jié)點(diǎn)名,第二個(gè)節(jié)點(diǎn)為node2
path.data: /data/elk_data ##數(shù)據(jù)存放位置
path.logs: /var/log/elasticsearch/ ##日志存放位置
bootstrap.memory_lock: false ##不在啟動(dòng)時(shí)鎖定內(nèi)存
network.host: 0.0.0.0 ##提供服務(wù)綁定的IP地址,為所有地址
http.port: 9200 ##端口號(hào)為9200
discovery.zen.ping.unicast.hosts: ["node1", "node2"] ##集群發(fā)現(xiàn)通過(guò)單播實(shí)現(xiàn)
[root@node1 elasticsearch]# grep -v "^#" /etc/elasticsearch/elasticsearch.yml ##檢查配置是否正確
cluster.name: my-elk-cluster
node.name: node1
path.data: /data/elk_data
path.logs: /var/log/elasticsearch/
bootstrap.memory_lock: false
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["node1", "node2"]
[root@node1 elasticsearch]# mkdir -p /data/elk_data ##創(chuàng)建數(shù)據(jù)存放點(diǎn)
[root@node1 elasticsearch]# chown elasticsearch.elasticsearch /data/elk_data/ ##給權(quán)限
[root@node1 elasticsearch]# systemctl start elasticsearch.service ##開(kāi)啟服務(wù)
[root@node1 elasticsearch]# netstat -ntap | grep 9200 ##查看開(kāi)啟情況
tcp6 0 0 :::9200 :::* LISTEN 83358/java
[root@node1 elasticsearch]#
查看node1節(jié)點(diǎn)信息
查看node2節(jié)點(diǎn)信息
node1健康檢查
node2健康檢查
node1狀態(tài)
node2狀態(tài)
[root@node1 elasticsearch]# yum install gcc gcc-c++ make -y ##安裝編譯工具
[root@node1 elasticsearch]# cd /mnt/tools/elk/
[root@node1 elk]# tar xf node-v8.2.1.tar.gz -C /opt/ ##解壓插件
[root@node1 elk]# cd /opt/node-v8.2.1/
[root@node1 node-v8.2.1]# ./configure ##配置
[root@node1 node-v8.2.1]# make && make install ##編譯安裝
[root@node1 node-v8.2.1]# cd /mnt/tools/elk/
[root@node1 elk]# tar xf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/src/
##解壓到/usr/local/src下
[root@node1 elk]# cd /usr/local/src/phantomjs-2.1.1-linux-x86_64/bin/
[root@node1 bin]# cp phantomjs /usr/local/bin/ ##編譯系統(tǒng)識(shí)別
[root@node1 bin]# cd /mnt/tools/elk/
[root@node1 elk]# tar xf elasticsearch-head.tar.gz -C /usr/local/src/ ##解壓
[root@node1 elk]# cd /usr/local/src/elasticsearch-head/
[root@node1 elasticsearch-head]# npm install ##安裝
npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
added 71 packages in 7.262s
[root@node1 elasticsearch-head]#
[root@node1 elasticsearch-head]# cd ~
[root@node1 ~]# vim /etc/elasticsearch/elasticsearch.yml
#末行插入
http.cors.enabled: true ##開(kāi)啟跨域訪問(wèn)支持,默認(rèn)為false
http.cors.allow-origin: "*" ##跨域訪問(wèn)允許的域名地址
[root@node1 ~]# systemctl restart elasticsearch.service ##重啟
[root@node1 ~]# cd /usr/local/src/elasticsearch-head/
[root@node1 elasticsearch-head]# npm run start & ##后臺(tái)運(yùn)行數(shù)據(jù)可視化服務(wù)
[1] 83664
[root@node1 elasticsearch-head]#
> elasticsearch-head@0.0.0 start /usr/local/src/elasticsearch-head
> grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
[root@node1 elasticsearch-head]#
[root@node1 elasticsearch-head]# netstat -ntap | grep 9200
tcp6 0 0 :::9200 :::* LISTEN 83358/java
[root@node1 elasticsearch-head]# netstat -ntap | grep 9100
tcp 0 0 0.0.0.0:9100 0.0.0.0:* LISTEN 83674/grunt
[root@node1 elasticsearch-head]#
node1
node2
[root@node2 ~]# curl -XPUT 'localhost:9200/index-demo/test/1?pretty&pretty' -H 'content-Type: application/json' -d '{"user":"zhangsan","mesg":"hello world"}'
##創(chuàng)建索引信息
{
"_index" : "index-demo",
"_type" : "test",
"_id" : "1",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 2,
"failed" : 0
},
"created" : true
}
[root@node1 ~]#
[root@apache ~]# systemctl stop firewalld.service
[root@apache ~]# setenforce 0
[root@apache ~]# yum install httpd -y ##安裝服務(wù)
[root@apache ~]# systemctl start httpd.service ##啟動(dòng)服務(wù)
[root@apache ~]# java -version
[root@apache ~]# mount.cifs //192.168.100.100/tools /mnt/tools/ ##掛載
Password for root@//192.168.100.100/tools:
[root@apache ~]# cd /mnt/tools/elk/
[root@apache elk]# rpm -ivh logstash-5.5.1.rpm ##安裝logstash
警告:logstash-5.5.1.rpm: 頭V4 RSA/SHA512 Signature, 密鑰 ID d88e42b4: NOKEY
準(zhǔn)備中... ################################# [100%]
正在升級(jí)/安裝...
1:logstash-1:5.5.1-1 ################################# [100%]
Using provided startup.options file: /etc/logstash/startup.options
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
Successfully created system startup script for Logstash
[root@apache elk]# systemctl start logstash.service ##開(kāi)啟服務(wù)
[root@apache elk]# systemctl enable logstash.service ##開(kāi)機(jī)自啟
Created symlink from /etc/systemd/system/multi-user.target.wants/logstash.service to /etc/systemd/system/logstash.service.
[root@apache elk]# ln -s /usr/share/logstash/bin/logstash /usr/local/bin/ ##便于系統(tǒng)識(shí)別
[root@apache elk]#
[root@apache elk]# chmod o+r /var/log/messages ##給其他用戶讀權(quán)限
[root@apache elk]# vim /etc/logstash/conf.d/system.conf ##創(chuàng)建文件
input {
file{
path => "/var/log/messages" ##輸出目錄
type => "system"
start_position => "beginning"
}
}
output {
elasticsearch {
#輸入地址指向node1節(jié)點(diǎn)
hosts => ["192.168.13.129:9200"]
index => "system-%{+YYYY.MM.dd}"
}
}
[root@apache elk]# systemctl restart logstash.service ##重啟服務(wù)
##也可以用數(shù)據(jù)瀏覽查看詳細(xì)信息
[root@node1 ~]# cd /mnt/tools/elk/
[root@node1 elk]# rpm -ivh kibana-5.5.1-x86_64.rpm ##安裝
警告:kibana-5.5.1-x86_64.rpm: 頭V4 RSA/SHA512 Signature, 密鑰 ID d88e42b4: NOKEY
準(zhǔn)備中... ################################# [100%]
正在升級(jí)/安裝...
1:kibana-5.5.1-1 ################################# [100%]
[root@node1 elk]# cd /etc/kibana/
[root@node1 kibana]# cp kibana.yml kibana.yml.bak ##備份
[root@node1 kibana]# vim kibana.yml ##修改配置文件
server.port: 5601 ##端口號(hào)
server.host: "0.0.0.0" ##監(jiān)聽(tīng)任意網(wǎng)段
elasticsearch.url: "http://192.168.13.129:9200" ##本機(jī)節(jié)點(diǎn)地址
kibana.index: ".kibana" ##索引名稱
[root@node1 kibana]# systemctl start kibana.service ##開(kāi)啟服務(wù)
[root@node1 kibana]# systemctl enable kibana.service ##開(kāi)機(jī)自啟
Created symlink from /etc/systemd/system/multi-user.target.wants/kibana.service to /etc/systemd/system/kibana.service.
[root@node1 elk]#
[root@node1 elk]# netstat -ntap | grep 5601 ##查看端口
tcp 0 0 127.0.0.1:5601 0.0.0.0:* LISTEN 84837/node
[root@node1 elk]#
[root@apache elk]# vim /etc/logstash/conf.d/apache_log.conf ##創(chuàng)建配置文件
input {
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" { ##根據(jù)條件判斷輸出信息
elasticsearch {
hosts => ["192.168.13.129:9200"]
index => "apache_access-%{+YYYY.MM.dd}"
}
}
if [type] == "error" {
elasticsearch {
hosts => ["192.168.13.129:9200"]
index => "apache_error-%{+YYYY.MM.dd}"
}
}
}
[root@apache elk]# logstash -f /etc/logstash/conf.d/apache_log.conf
##根據(jù)配置文件配置logstach
只有error日志
瀏覽器訪問(wèn)Apache服務(wù)
生成access日志
##選擇management>Index Patterns>create index patterns
##創(chuàng)建apache兩個(gè)日志的信息
在kibana創(chuàng)建access訪問(wèn)日志
在kibana創(chuàng)建error訪問(wèn)日志
查看access日志統(tǒng)計(jì)情況
查看error日志統(tǒng)計(jì)情況
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
當(dāng)前題目:ELK日志分析系統(tǒng)(實(shí)戰(zhàn)!)-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://chinadenli.net/article30/dhppso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣、Google、網(wǎng)站收錄、軟件開(kāi)發(fā)、網(wǎng)站改版、網(wǎng)站營(yíng)銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容