英文官方文檔:https://docs.splunk.com/Documentation
中文手冊:
https://docs.splunk.com/Documentation/Splunk/7.3.2/Translated/SimplifiedChinesemanuals
https://www.tuicool.com/articles/zErQFnr
參考文章:
https://blog.csdn.net/liangkaiping0525/article/details/81063563
https://blog.csdn.net/a1043498776/article/details/68500059
https://blog.51cto.com/215687833/1762344
https://www.cnblogs.com/Eleven-Liu/p/7193959.html
splunk分爲服務器和客戶端,需要下載兩個安裝包。
下載splunk:https://www.splunk.com/en_us/download/splunk-enterprise.html 需要先註冊賬戶。
這裏我下載的是7.3.2版本的。
還要下載splunkforwarder:https://www.splunk.com/page/previous_releases/universalforwarder#x86_64linux
下載的是7.3.2版本。
安裝包路徑:
解壓:
[root@localhost wyh]# tar -zxvf splunk-7.3.2-c60db69f8e32-Linux-x86_64.tgz
[root@localhost wyh]# tar -zxvf splunkforwarder-7.3.2-c60db69f8e32-Linux-x86_64.tgz
先檢查一下防火牆是否關閉,如果啓動着的,需要關閉防火牆:
關閉防火牆:
[root@localhost ~]# systemctl disable firewalld
重啓。
再次查看狀態:
啓動splunk:
進入安裝包的bin目錄下,啓動splunk:
[root@localhost bin]# pwd
/usr/local/wyh/splunk/bin
[root@localhost bin]# ./splunk start
啓動之後會有很多信息,沒有完全展示就停在那裏,就按回車鍵按到最後會出現提示信息,輸入y:
Do you agree with this license? [y/n]: y
第一次登陸時默認的用戶名:admin,密碼:changeme:
如下表示啓動成功:
然後我們去web頁面中訪問一下:
首次登陸使用默認用戶:
啓動splunkforwarder:
進入splunkforwarder下的bin目錄,啓動splunkforwarder:
如果splunk和spluknforwarder安裝在同一臺機器上,splunkforwarder的端口號也是8089,就會在啓動過程中提示8089端口號被佔用,根據提示我把端口號改爲8001(通常我們是在需要收集日誌的服務器上安裝splunkforwarder):
splunkforwarder沒有web界面。
=====================================================
在server的web頁面設置轉發和接收:
新增一個接收數據的配置:
這裏配置了9997爲接收數據的端口:
保存成功:
簡單的應用實例:
監控log文件中的數據存儲到splunk中。
1.在需要收集日誌的服務器上安裝splunkforwarder,這裏我們安裝在了同一臺機器上,安裝步驟如上。
2.進入spluknforwarder/bin目錄下,啓動splunkforwarder。
3.在spluknforwarder/bin下查看端口號:
4.創建一個用於測試的log文件:
5.在splunk/bin下使用命令創建索引:
6.在splunkforwarder/bin下執行命令添加一個監控項:
[root@localhost bin]# ./splunk add monitor /usr/local/wyh/splunkforwarder/wyh-log/test.log -index wyh-test-index
7.在splunkforwarder端添加splunk server(服務器端)所在機器的 ip及端口號(這個端口號是之前在splunk端新增設置的):
[root@localhost bin]# ./splunk add forward-server 192.168.47.128:9997
Added forwarding to: 192.168.47.128:9997.
8.在splunk的web中搜索查看剛纔建好的index:
在搜索框中輸入index="要搜索的index名稱",點擊右邊的搜索按鈕即可看到剛纔我們要監控的log文件中的信息。
這樣應該就是暫時完成了一個splunk的入門案例。