ELK整合Filebeat監控nginx日志



ELK 日志分析

1. 為什么用到 ELK

一般我們需要進行日志分析場景:直接在日志文件中 grepawk 就可以獲得自己想要的信息。
但在規模較大的場景中,此方法效率低下,面臨問題包括日志量太大如何歸檔、文本搜索太慢怎么辦、
如何多維度查詢。需要集中化的日志管理,所有服務器上的日志收集匯總。常見解決思路是建立集中
式日志收集系統,將所有節點上的日志統一收集,管理,訪問。


一般大型系統是一個分布式部署的架構,不同的服務模塊部署在不同的服務器上,問題出現時,
大部分情況需要根據問題暴露的關鍵信息,定位到具體的服務器和服務模塊,構建一套集中式日志系
統,可以提高定位問題的效率。


一個完整的集中式日志系統,需要包含以下幾個主要特點:
收集-能夠采集多種來源的日志數據
傳輸-能夠穩定的把日志數據傳輸到中央系統
存儲-如何存儲日志數據
分析-可以支持 UI 分析
警告-能夠提供錯誤報告,監控機制 ELK 提供了一整套解決方案,並且都是開源軟件,之間互相配
合使用,完美銜接,高效的滿足了很多場合的應用。目前主流的一種日志系統。

2.ELK簡介

ELK 是三個開源軟件的縮寫,分別表示: Elasticsearch , Logstash, Kibana , 它們都是開源軟件。新增了
一個 FileBeat,它是一個輕量級的日志收集處理工具(Agent)Filebeat 占用資源少,適合於在各個服務
器上搜集日志后傳輸給 Logstash,官方也推薦此工具。
Elasticsearch 是個開源分布式搜索引擎,提供搜集、分析、存儲數據三大功能。它的特點有:分布式,
零配置,自動發現,索引自動分片,索引副本機制, restful 風格接口,多數據源,自動搜索負載等。
Logstash 主要是用來日志的搜集、分析、過濾日志的工具,支持大量的數據獲取方式。一般工作方式
c/s 架構, client 端安裝在需要收集日志的主機上, server 端負責將收到的各節點日志進行過濾、修
改等操作在一並發往 elasticsearch 上去。
Kibana 也是一個開源和免費的工具, Kibana 可以為 Logstash ElasticSearch 提供的日志分析友好
Web 界面,可以幫助匯總、分析和搜索重要數據日志。
Filebeat 隸屬於 Beats。目前 Beats 包含四種工具:
Packetbeat(搜集網絡流量數據)
Topbeat(搜集系統、進程和文件系統級別的 CPU 和內存使用情況等數據)
Filebeat(搜集文件數據)
Winlogbeat(搜集 Windows 事件日志數據)

3. 實驗部署

本次部署的是 filebeats(客戶端)logstash+elasticsearch+kibana(服務端)組成的架構。
業務請求到達 nginx-server 機器上的 NginxNginx 響應請求,並在 access.log 文件中增加訪問記
錄; FileBeat 搜集新增的日志,通過 LogStash 5044 端口上傳日志; LogStash 將日志信息通過本
機的 9200 端口傳入到 ElasticSerach; 搜索日志的用戶通過瀏覽器訪問 Kibana,服務器端口是 5601
Kibana 通過 9200 端口訪問 ElasticSerach

 

 

 


實驗環境:
本次部署的是單點 ELK 用了兩台機器(CentOS7)
ELK 服務端: 192.168.180.113
Nginx 客戶端: 192.168.180.112
1. 准備工作:
配置好網絡 yum

# wget http://mirrors.aliyun.com/repo/Centos-7.repo
# wget http://mirrors.aliyun.com/repo/epel-7.repo
關閉防火牆: systemctl stop(disable) firewalld
關閉 SELinux: SELINUX=disabled

2. 下載並安裝軟件包:

# mkdir /elk;cd /elk
# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.3.tar.gz
# wget https://artifacts.elastic.co/downloads/logstash/logstash-6.2.3.tar.gz
# wget https://artifacts.elastic.co/downloads/kibana/kibana-6.2.3-linux-x86_64.tar.gz

全部解壓縮,並復制到/usr/local/目錄下
3. 安裝 JDK(java)環境工具:

# yum -y install java-1.8*

4. 配置 elasticsearch

1) 新建 elasticsearch 用戶並啟動(elasticsearch 普通用戶啟動)

# useradd es
# chown -R elasticsearch.elasticsearch /mnt/elasticsearch-6.2.3/
[root@topcheer elasticsearch-6.2.3]# su - es
上一次登錄:日 9月 29 22:53:43 CST 2019pts/1 上
[es@topcheer ~]$ cd /mnt
[es@topcheer mnt]$ ll
總用量 4175516
drwxr-xr-x  9 root root       160 10月  4 20:30 apache-tomcat-7.0.70
drwxr-xr-x  9 root root       160 11月  4 01:25 apache-tomcat-7.0.70_1
-rw-r--r--  1 root root   8924465 10月  4 20:30 apache-tomcat-7.0.70.tar.gz
-rw-r--r--  1 root root       540 9月  21 22:14 Dockerfile
drwxr-xr-x  9 es   es         155 9月  21 22:58 elasticsearch-6.2.3
-rw-r--r--  1 root root  29050159 9月  21 22:45 elasticsearch-6.2.3.tar.gz
-rw-r--r--  1 root root       128 9月  29 21:47 elasticsearch.yml
-rw-r--r--  1 root root 780598784 9月  29 21:27 es.tar
-rw-r--r--  1 root root 412774002 5月  30 2018 gitlab-ce-10.8.2-ce.0.el7.x86_64.rpm
drwxr-xr-x  2 root root       100 11月  4 01:08 harbor
-rw-r--r--  1 root root 552897681 11月  4 01:07 harbor-offline-installer-v1.8.0.tgz
-rw-r--r--  1 root root 619113214 11月  4 00:38 harbor-offline-installer-v1.9.1.tgz
-rw-r--r--  1 root root  78245883 9月  30 14:25 jenkins.war
drwxrwxr-x 12 wgr  wgr        249 9月  21 23:34 kibana-6.2.3-linux-x86_64
-rw-r--r--  1 root root  83426328 9月  21 22:45 kibana-6.2.3-linux-x86_64.tar.gz
-rw-r--r--  1 root root 768809984 9月  29 21:29 kibana.tar
-rw-r--r--  1 root root  17446309 9月  21 22:12 logstash-0.0.1-SNAPSHOT.jar
drwxr-xr-x 12 root root       289 9月  22 12:32 logstash-6.2.3
-rw-r--r--  1 root root 138221072 9月  21 22:45 logstash-6.2.3.tar.gz
-rw-r--r--  1 root root 677771264 9月  29 21:31 logstash.tar
drwxrwxr-x  3 root root        48 8月   4 2018 __MACOSX
drwxr-xr-x 10 root root       171 10月 24 23:34 nacos
-rw-r--r--  1 root root  44275341 10月 24 23:25 nacos.tar.gz
drwxr-xr-x  9 es   es         186 10月  4 21:41 nginx-1.12.2
-rw-r--r--  1 root root    981687 10月  4 20:30 nginx-1.12.2.tar.gz
drwxr-xr-x  9 1169 1169     12288 10月  4 21:40 pcre-8.37
-rw-r--r--  1 root root   2041593 10月  4 20:30 pcre-8.37.tar.gz
drwxr-xr-x 19 root root      4096 11月 19 21:41 Python-3.7.0
-rw-r--r--  1 root root  26047619 11月 19 21:33 Python-3.7.0.zip
drwxr-xr-x 11 es   es        4096 10月  6 16:52 zookeeper-3.4.10
-rw-r--r--  1 root root  35042811 10月  6 15:27 zookeeper-3.4.10.tar.gz
[es@topcheer mnt]$ cd elasticsearch-6.2.3/
[es@topcheer elasticsearch-6.2.3]$ ll
總用量 220
drwxr-xr-x  2 es es   4096 9月  21 22:49 bin
drwxr-xr-x  2 es es     75 9月  29 22:48 config
drwxrwxr-x  3 es es     19 9月  21 22:58 data
drwxr-xr-x  2 es es   4096 3月  13 2018 lib
-rw-r--r--  1 es es  11358 3月  13 2018 LICENSE.txt
drwxr-xr-x  2 es es    268 9月  29 22:44 logs
drwxr-xr-x 16 es es    289 3月  13 2018 modules
-rw-r--r--  1 es es 191887 3月  13 2018 NOTICE.txt
drwxr-xr-x  2 es es      6 3月  13 2018 plugins
-rw-r--r--  1 es es   9268 3月  13 2018 README.textile
[es@topcheer elasticsearch-6.2.3]$ ./bin/elasticsearch -d

 

2) 查看進程是否啟動成功(等待一下)

[es@topcheer elasticsearch-6.2.3]$ lsof -i:9200
[es@topcheer elasticsearch-6.2.3]$ netstat -antp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN      -
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      -
tcp        0      0 192.168.180.113:22      192.168.180.1:65135     ESTABLISHED -
tcp        0      0 192.168.180.113:22      192.168.180.1:65130     ESTABLISHED -
tcp        0      1 192.168.180.113:44876   192.168.77.129:2377     SYN_SENT    -
tcp6       0      0 :::2377                 :::*                    LISTEN      -
tcp6       0      0 :::27017                :::*                    LISTEN      -
tcp6       0      0 :::8009                 :::*                    LISTEN      -
tcp6       0      0 :::7946                 :::*                    LISTEN      -
tcp6       0      0 :::3306                 :::*                    LISTEN      -
tcp6       0      0 :::6061                 :::*                    LISTEN      -
tcp6       0      0 :::6062                 :::*                    LISTEN      -
tcp6       0      0 :::111                  :::*                    LISTEN      -
tcp6       0      0 :::80                   :::*                    LISTEN      -
tcp6       0      0 :::8080                 :::*                    LISTEN      -
tcp6       0      0 :::6000                 :::*                    LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 ::1:631                 :::*                    LISTEN      -
tcp6       0      0 :::23                   :::*                    LISTEN      -
tcp6       0      0 ::1:25                  :::*                    LISTEN      -
tcp6       0      0 ::1:6010                :::*                    LISTEN      -
tcp6       0      0 :::8091                 :::*                    LISTEN      -
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      

3) 若出現錯誤可以查看日志

[es@topcheer elasticsearch-6.2.3]$ cd logs/
[es@topcheer logs]$ ll
總用量 60
-rw-rw-r-- 1 es es  2836 9月  22 00:01 elasticsearch-2019-09-21-1.log.gz
-rw-rw-r-- 1 es es  1470 9月  29 22:44 elasticsearch-2019-09-22-1.log.gz
-rw-rw-r-- 1 es es  2956 12月  2 10:06 elasticsearch-2019-09-29-1.log.gz
-rw-rw-r-- 1 es es  1593 9月  22 10:21 elasticsearch_deprecation.log
-rw-rw-r-- 1 es es     0 9月  21 22:58 elasticsearch_index_indexing_slowlog.log
-rw-rw-r-- 1 es es     0 9月  21 22:58 elasticsearch_index_search_slowlog.log
-rw-rw-r-- 1 es es  4214 12月  2 10:06 elasticsearch.log
-rw-rw-r-- 1 es es 34796 12月  2 10:06 gc.log.0.current
[es@topcheer logs]$ cat elasticsearch.log
[2019-12-02T10:06:40,446][INFO ][o.e.n.Node               ] [] initializing ...
[2019-12-02T10:06:40,891][INFO ][o.e.e.NodeEnvironment    ] [Wq-vR0u] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [3gb], net total_space [26.9gb], types [rootfs]
[2019-12-02T10:06:40,892][INFO ][o.e.e.NodeEnvironment    ] [Wq-vR0u] heap size [990.7mb], compressed ordinary object pointers [true]
[2019-12-02T10:06:41,530][INFO ][o.e.n.Node               ] node name [Wq-vR0u] derived from node ID [Wq-vR0uFTRGwj2HQ0-vyqw]; set [node.name] to override
[2019-12-02T10:06:41,531][INFO ][o.e.n.Node               ] version[6.2.3], pid[33585], build[c59ff00/2018-03-13T10:06:29.741383Z], OS[Linux/3.10.0-957.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_181/25.181-b13]
[2019-12-02T10:06:41,531][INFO ][o.e.n.Node               ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.JndCl1Qt, -XX:+HeapDumpOnOutOfMemoryError, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/mnt/elasticsearch-6.2.3, -Des.path.conf=/mnt/elasticsearch-6.2.3/config]
[2019-12-02T10:06:43,796][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [aggs-matrix-stats]
[2019-12-02T10:06:43,796][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [analysis-common]
[2019-12-02T10:06:43,796][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [ingest-common]
[2019-12-02T10:06:43,796][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [lang-expression]
[2019-12-02T10:06:43,796][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [lang-mustache]
[2019-12-02T10:06:43,796][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [lang-painless]
[2019-12-02T10:06:43,796][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [mapper-extras]
[2019-12-02T10:06:43,796][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [parent-join]
[2019-12-02T10:06:43,796][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [percolator]
[2019-12-02T10:06:43,797][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [rank-eval]
[2019-12-02T10:06:43,797][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [reindex]
[2019-12-02T10:06:43,797][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [repository-url]
[2019-12-02T10:06:43,797][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [transport-netty4]
[2019-12-02T10:06:43,797][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] loaded module [tribe]
[2019-12-02T10:06:43,798][INFO ][o.e.p.PluginsService     ] [Wq-vR0u] no plugins loaded
[2019-12-02T10:06:54,458][INFO ][o.e.d.DiscoveryModule    ] [Wq-vR0u] using discovery type [zen]
[2019-12-02T10:06:55,374][INFO ][o.e.n.Node               ] initialized
[2019-12-02T10:06:55,374][INFO ][o.e.n.Node               ] [Wq-vR0u] starting ...
[2019-12-02T10:06:55,818][INFO ][o.e.t.TransportService   ] [Wq-vR0u] publish_address {172.17.0.1:9300}, bound_addresses {[::]:9300}
[2019-12-02T10:06:55,852][INFO ][o.e.b.BootstrapChecks    ] [Wq-vR0u] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2019-12-02T10:06:55,866][ERROR][o.e.b.Bootstrap          ] [Wq-vR0u] node validation exception
[1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2019-12-02T10:06:55,877][INFO ][o.e.n.Node               ] [Wq-vR0u] stopping ...
[2019-12-02T10:06:56,163][INFO ][o.e.n.Node               ] [Wq-vR0u] stopped
[2019-12-02T10:06:56,164][INFO ][o.e.n.Node               ] [Wq-vR0u] closing ...
[2019-12-02T10:06:56,196][INFO ][o.e.n.Node               ] [Wq-vR0u] closed
[es@topcheer logs]$

 

解決:

[root@topcheer ~]# sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144
[root@topcheer ~]#

 

[es@topcheer elasticsearch-6.2.3]$ ./bin/elasticsearch -d
[es@topcheer elasticsearch-6.2.3]$ lsof -i:9200
[es@topcheer elasticsearch-6.2.3]$ lsof -i:9200
COMMAND   PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
java    36864   es  174u  IPv6 83816708      0t0  TCP *:wap-wsp (LISTEN)
[es@topcheer elasticsearch-6.2.3]$ netstat -antp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN      -
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:6011          0.0.0.0:*               LISTEN      -
tcp        0      0 192.168.180.113:22      192.168.180.1:65135     ESTABLISHED -
tcp        0     36 192.168.180.113:22      192.168.180.1:65130     ESTABLISHED -
tcp        0      0 192.168.180.113:22      192.168.180.1:49838     ESTABLISHED -
tcp        0      0 192.168.180.113:22      192.168.180.1:49839     ESTABLISHED -
tcp        0      1 192.168.180.113:45014   192.168.77.129:2377     SYN_SENT    -
tcp6       0      0 :::2377                 :::*                    LISTEN      -
tcp6       0      0 :::27017                :::*                    LISTEN      -
tcp6       0      0 :::8009                 :::*                    LISTEN      -
tcp6       0      0 :::7946                 :::*                    LISTEN      -
tcp6       0      0 :::3306                 :::*                    LISTEN      -
tcp6       0      0 :::6061                 :::*                    LISTEN      -
tcp6       0      0 :::6062                 :::*                    LISTEN      -
tcp6       0      0 :::111                  :::*                    LISTEN      -
tcp6       0      0 :::9200                 :::*                    LISTEN      36864/java
tcp6       0      0 :::80                   :::*                    LISTEN      -
tcp6       0      0 :::8080                 :::*                    LISTEN      -
tcp6       0      0 :::6000                 :::*                    LISTEN      -
tcp6       0      0 :::9300                 :::*                    LISTEN      36864/java
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 ::1:631                 :::*                    LISTEN      -
tcp6       0      0 :::23                   :::*                    LISTEN      -
tcp6       0      0 ::1:25                  :::*                    LISTEN      -
tcp6       0      0 ::1:6010                :::*                    LISTEN      -
tcp6       0      0 ::1:6011                :::*                    LISTEN      -
tcp6       0      0 :::8091                 :::*                    LISTEN      -
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      -
tcp6       0      0 ::1:34054               ::1:9300                TIME_WAIT   -
tcp6       0      0 127.0.0.1:46130         127.0.0.1:9300          TIME_WAIT   -
[es@topcheer elasticsearch-6.2.3]

4) 測試是否可以正常訪問

[es@topcheer elasticsearch-6.2.3]$ curl localhost:9200
{
  "name" : "Wq-vR0u",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "PwmRsjs6Q_WrsRzqnZZlxQ",
  "version" : {
    "number" : "6.2.3",
    "build_hash" : "c59ff00",
    "build_date" : "2018-03-13T10:06:29.741383Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
[es@topcheer elasticsearch-6.2.3]$

 

5. 配置 logstash

Logstash 收集 nginx 日志之使用 grok 過濾插件解析日志, grok 作為一個 logstash 的過濾插件,支持根
據模式解析文本日志行,拆成字段。
1) logstash grok 的正則匹配

[root@topcheer patterns]# pwd
/mnt/logstash-6.2.3/vendor/bundle/jruby/2.3.0/gems/logstash-patterns-core-4.1.2/patterns
[root@topcheer patterns]# vim grok-patterns
WZ ([^ ]*)
NGINXACCESS %{IP:remote_ip}\-\-\[%{HTTPDATE:timestamp}\] "%{WORD:method} %{WZ:request}HTTP/%{NUMBER:httpversion}" %{NUMBER:status} %{NUMBER:bytes} %{QS:referer} %{QS:agent} %{QS:xforward}

2) 創建 logstash 配置文件

[root@topcheer logstash-6.2.3]# cat nginx.conf
input {
   beats {
   port => "5044"
}
}
#數據過濾
filter {
grok {
match => { "message" => "%{NGINXACCESS}" }
}
geoip {
# nginx客戶端ip
source => "192.168.180.112"
}
}
#輸出配置為本機的9200端口,這是ElasticSerach服務的監聽端口
output {
elasticsearch {
hosts => ["127.0.0.1:9200"]
}
}
[root@topcheer logstash-6.2.3]#

 


3) 進入到/usr/local/logstash-6.2.3 目錄下,並執行下列命令
后台啟動 logstash

[root@topcheer logstash-6.2.3]# nohup bin/logstash -f nginx.conf &
[1] 57261
[root@topcheer logstash-6.2.3]# nohup: 忽略輸入並把輸出追加到"nohup.out"

[root@topcheer logstash-6.2.3]# ll

查看啟動日志: tailf nohup.out

查看端口是否啟動:

[root@topcheer logstash-6.2.3]# netstat -napt|grep 5044
tcp6       0      0 :::5044                 :::*                    LISTEN      57261/java
[root@topcheer logstash-6.2.3]#

6. 配置 kibana
1) 打開 Kibana 配置文件config/kibana.yml,找到下面這行並修改
# vim /usr/local/kibana-6.2.3-linux-x86_64/config/kibana.yml
#server.host: "localhost"
修改為
server.host: "192.168.88.100"

這樣其他電腦就能用瀏覽器訪問 Kibana 的服務了;
2) 進入 Kibana 的目錄:
執行啟動命令:

[root@topcheer kibana-6.2.3-linux-x86_64]#  nohup bin/kibana &
[3] 61389
[root@topcheer kibana-6.2.3-linux-x86_64]# nohup: 忽略輸入並把輸出追加到"nohup.out"

[root@topcheer kibana-6.2.3-linux-x86_64]#

查看啟動日志: tail -f nohup.out

查看端口是否啟動: netstat -napt|grep 5601
3) 測試:
在瀏覽器訪問 192.168.88.100:5601

到此。 ELK 部署完成

7. Nginx 客戶端配置

1) yum 安裝二進制 nginx 軟件包# yum -y install nginx

啟動:

[root@topcheer log]# lsof -i:80
[root@topcheer log]# systemctl start nginx
[root@topcheer log]# lsof -i:80
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   57650  root    6u  IPv4 695998      0t0  TCP *:http (LISTEN)
nginx   57650  root    7u  IPv6 695999      0t0  TCP *:http (LISTEN)
nginx   57651 nginx    6u  IPv4 695998      0t0  TCP *:http (LISTEN)
nginx   57651 nginx    7u  IPv6 695999      0t0  TCP *:http (LISTEN)
nginx   57652 nginx    6u  IPv4 695998      0t0  TCP *:http (LISTEN)
nginx   57652 nginx    7u  IPv6 695999      0t0  TCP *:http (LISTEN)

 

2) 下載 filebeat 並解壓

 

 

3) 切換到/usr/local/filebeat-6.2.3-linux-x86_64 目錄下

[root@topcheer log]# cd /mnt/filebeat-6.2.3-linux-x86_64/
[root@topcheer filebeat-6.2.3-linux-x86_64]# ll
總用量 48224
-rw-r--r--.  1 root root    44384 3月  13 2018 fields.yml
-rwxr-xr-x.  1 root root 49058867 3月  13 2018 filebeat
-rw-r-----.  1 root root    52193 3月  13 2018 filebeat.reference.yml
-rw-------.  1 root root     7275 12月  2 11:10 filebeat.yml
drwxrwxr-x.  4 wgr  wgr        24 3月  13 2018 kibana
-rw-r--r--.  1 root root      583 3月  13 2018 LICENSE.txt
drwxr-xr-x. 14 wgr  wgr       179 3月  13 2018 module
drwxr-xr-x.  2 root root     4096 3月  13 2018 modules.d
-rw-r--r--.  1 root root   198236 3月  13 2018 NOTICE.txt
-rw-r--r--.  1 root root      802 3月  13 2018 README.md
[root@topcheer filebeat-6.2.3-linux-x86_64]# nohup ./filebeat -e -c filebeat.yml &
[2] 57668
[root@topcheer filebeat-6.2.3-linux-x86_64]# nohup: 忽略輸入並把輸出追加到"nohup.out"

[root@topcheer filebeat-6.2.3-linux-x86_64]# ll
總用量 48228
drwxr-x---.  2 root root       39 12月  2 12:25 data
-rw-r--r--.  1 root root    44384 3月  13 2018 fields.yml
-rwxr-xr-x.  1 root root 49058867 3月  13 2018 filebeat
-rw-r-----.  1 root root    52193 3月  13 2018 filebeat.reference.yml
-rw-------.  1 root root     7275 12月  2 11:10 filebeat.yml
drwxrwxr-x.  4 wgr  wgr        24 3月  13 2018 kibana
-rw-r--r--.  1 root root      583 3月  13 2018 LICENSE.txt
drwxr-xr-x. 14 wgr  wgr       179 3月  13 2018 module
drwxr-xr-x.  2 root root     4096 3月  13 2018 modules.d
-rw-------.  1 root root     2093 12月  2 12:25 nohup.out
-rw-r--r--.  1 root root   198236 3月  13 2018 NOTICE.txt
-rw-r--r--.  1 root root      802 3月  13 2018 README.md
[root@topcheer filebeat-6.2.3-linux-x86_64]# tail -200f nohup.out
2019-12-02T12:25:36.421+0800    INFO    instance/beat.go:468    Home path: [/mnt/filebeat-6.2.3-linux-x86_64] Config path: [/mnt/filebeat-6.2.3-linux-x86_64] Data path: [/mnt/filebeat-6.2.3-linux-x86_64/data] Logs path: [/mnt/filebeat-6.2.3-linux-x86_64/logs]
2019-12-02T12:25:36.422+0800    INFO    instance/beat.go:475    Beat UUID: 6e3ca243-535f-4f7b-946d-c1172536d8f5
2019-12-02T12:25:36.422+0800    INFO    instance/beat.go:213    Setup Beat: filebeat; Version: 6.2.3
2019-12-02T12:25:36.423+0800    INFO    pipeline/module.go:76   Beat name: topcheer
2019-12-02T12:25:36.425+0800    INFO    [monitoring]    log/log.go:97   Starting metrics logging every 30s
2019-12-02T12:25:36.426+0800    INFO    instance/beat.go:301    filebeat start running.
2019-12-02T12:25:36.426+0800    INFO    registrar/registrar.go:71       No registry file found under: /mnt/filebeat-6.2.3-linux-x86_64/data/registry. Creating a new registry file.
2019-12-02T12:25:36.427+0800    INFO    registrar/registrar.go:108      Loading registrar data from /mnt/filebeat-6.2.3-linux-x86_64/data/registry
2019-12-02T12:25:36.427+0800    INFO    registrar/registrar.go:119      States Loaded from registrar: 0
2019-12-02T12:25:36.427+0800    WARN    beater/filebeat.go:261  Filebeat is unable to load the Ingest Node pipelines for the configured modules because the Elasticsearch output is not configured/enabled. If you have already loaded the Ingest Node pipelines or are using Logstash pipelines, you can ignore this warning.

4) 訪問 Kibanahttps://192.168.180.113:5601,點擊左上角的 Discover,就可以看到訪問日志已經被

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM