在本文中,我將解釋如何在 Ubuntu 18.04 服務器上安裝最新的 Splunk。 Splunk 旨在處理數據以使其對用戶有用,而無需處理原始數據。 它是分析、探索和搜索數據的最強大工具之一。 它是從應用程序、Web 服務器、數據庫、服務器平台實時索引、搜索、收集和可視化大量數據流的最簡單方法之一, Cloud-網絡等等。
Splunk 架構
Splunk 中包含三個主要組件,如下所示:
- Splunk 轉發器
- Splunk 索引器
- Splunk 搜索頭
如您所見,Splunk Forwarder 用於數據轉發。 它是用於收集日誌的組件。 Splunk Indexer 是一種用於解析和索引數據的索引器。 Splunk 實例將傳入的數據轉換為事件並將其存儲在索引中以高效執行搜索操作。 最後是 Splunk 搜索頭,它是一個圖形界面,用於搜索、分析和報告。
在 Ubuntu 18.04 上安裝 Splunk
創建 Splunk 帳戶並從其下載 Splunk Enterprise 軟件 官方網站 這裡。
現在將下載的文件上傳到您的 Ubuntu 18.04 服務器並將其放在一個臨時目錄中。 接下來,我們可以運行 dpkg
命令來安裝 Splunk 服務器。
# dpkg -i splunk-7.1.0-2e75b3406c5b-linux-2.6-amd64.deb
Selecting previously unselected package splunk.
(Reading database ... 66600 files and directories currently installed.)
Preparing to unpack splunk-7.1.0-2e75b3406c5b-linux-2.6-amd64.deb ...
Unpacking splunk (7.1.0) ...
Setting up splunk (7.1.0) ...
complete
其次,我們需要創建 init.d
腳本,以便我們可以輕鬆啟動和停止 Splunk。 切換到 Splunk 二進制目錄,地址為 /選擇/斯普朗克/垃圾桶/ 並使用以下參數運行 Splunk 可執行文件。
#cd /opt/splunk/bin/
# ./splunk enable boot-start
Splunk Software License Agreement 04.24.2018
Do you agree with this license? [y/n]: y
Do you agree with this license? [y/n]: y
This appears to be your first time running this version of Splunk.
An Admin password must be set before installation proceeds.
Password must contain at least:
* 8 total printable ASCII character(s).
Please enter a new password:
Please confirm new password:
Copying '/opt/splunk/etc/openldap/ldap.conf.default' to '/opt/splunk/etc/openldap/ldap.conf'.
Generating RSA private key, 2048 bit long modulus
.......+++
................+++
e is 65537 (0x10001)
writing RSA key
Generating RSA private key, 2048 bit long modulus
.............................................................+++
............+++
e is 65537 (0x10001)
writing RSA key
Moving '/opt/splunk/share/splunk/search_mrsparkle/modules.new' to '/opt/splunk/share/splunk/search_mrsparkle/modules'.
Init script installed at /etc/init.d/splunk.
Init script is configured to run at boot.
在此過程中,您可以 Press the Spacebar
瀏覽許可協議,然後輸入 Y
接受它,如安裝日誌中所示。 最後,我們可以使用以下命令啟動 Splunk 服務:
# service splunk start
現在您可以通過以下網址訪問您的 Splunk Web 界面 https://Server-IP:8000/ or https://Server-hostname:8000
. 您需要確保在您的服務器防火牆上打開此端口 8000。
您可以提供 admin 在安裝階段創建的登錄憑據以訪問您的 Splunk GUI 界面。 登錄後,您就可以使用 Splunk Dashboard。
主頁上列出了不同的類別。 您可以選擇所需的一個並啟動 Splunking。
添加任務
我正在添加一個 example 用於添加到 Splunk 系統的簡單任務。 只需查看我的快照即可了解我是如何添加它的。 我的任務是添加 /var/日誌 文件夾到 Splunk 系統進行監控。
步驟1:
打開 Splunk Web 界面並選擇添加數據選項開始。
第2步:
添加數據選項卡打開三個選項:上傳、監控和轉發。 每個選項都是不言自明的,並附有目的的簡短描述。 這裡我們的任務是監控一個文件夾,所以我們繼續使用 Monitor。
在 Monitor 選項中,有以下四個類別:
Files & Directories:
監視文件/文件夾
HTTP Event Collector:
通過 HTTP 監控數據流
TCP/ UDP:
監控 TCP/UDP 端口上的流量
Scripts:
監控自定義腳本或命令
第 3 步:
根據我們的目的,我選擇 Files & Directories
選項。
步驟4:
現在,我正在瀏覽確切的文件夾路徑 /var/log
從服務器監控。 選擇設置後,您可以單擊下一步和查看。
檢查完所有設置後,您可以單擊 'Submit'
得出結論。
第 5 步:
現在您已成功將數據源添加到 Splunk 進行監控。 您可以根據需要開始搜索和監控日誌文件。 我已經將日誌縮小到 Apache 服務器上的應用程序。
這只是一個簡單的 example 對於 Splunking,您可以向其中添加盡可能多的任務並探索您的本地或遠程服務器數據。 它還為您提供了根據您的日誌分析使用多個字段和指標創建表格和可視化的工具。
另請閱讀:
- 如何在 CentOS 7 上安裝 Splunk
- Angle Grinder – 在 Linux 中格式化和解析日誌文件的工具
Splunk 是絕對的 admin 日誌處理的解決方案。 它是一個終極的日誌收集和分析工具。 我希望這篇文章對你有用。 我建議您對此提出寶貴的建議和意見。 快樂Splunking!!