Splunkをインストールしてみる!


Splunkとは?

いろんなログをリアルタイムに収集・蓄積して、柔軟かつ複雑な検索および分析を得意とする統合ログ管理ソフトウェアです。

Splunkの主な特徴として下記になります。

1. ログの種類やフォーマットにかかわらずテキスト形式であれば取り込むことができる
2. 各ログ間を相関的に分析することができる
3. SPL(Splunkサーチ処理言語)を用いた抽出ロジック保存することで誰でも分析対応が容易となる

今回やること

今回はSplunkをインストールしてSplunkAll-in-oneを構築していきます。
ライセンスが無くとも60日間は無償ですべての機能が利用可能となります。
※期限が切れても、一部機能の制限と対応容量が500Gbyteまでとなりますが利用はできます。

環境

  • OS:Amazon Linux 2
  • Splunkのインストールバージョン:8.1.3
  • セキュリティグループで以下利用ポートを穴あけしておく
ポート番号 用途
22 SSH用
8000 SplunkWebブラウザ用
8089 Splunk管理通信用
9997 データ転送用

ダウンロード方法

以下Splunkを公式サイトからサイトに遷移してログインします。
※事前にアカウントの登録が必要となります。
https://www.splunk.com/ja_jp/download/splunk-enterprise.html

タブでLinuxを選択して64-bitの.rpmの「Download Now」をクリックしてダウンロードします。
※ダウンロードしたファイルは「/home/ec2-user」配下に格納しておきます。

参考

以下Splunkの公式ドキュメントを参考にして進めました。
https://docs.splunk.com/Documentation/Splunk/8.1.3/Installation/InstallonLinux

Splunk のインストール手順

①Splunkをインストールする(rpm)

インストール時にインストール先を指定してない場合は、「/opt」配下にインストールされます。

$ sudo su -
#
# cd /home/ec2-user/
#
# ls
splunk-8.1.3-63079c59e632-linux-2.6-x86_64.rpm
#
# rpm -i splunk-8.1.3-63079c59e632-linux-2.6-x86_64.rpm
warning: splunk-8.1.3-63079c59e632-linux-2.6-x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID b3cd4420: NOKEY
cp: cannot stat ‘/opt/splunk/etc/regid.2001-12.com.splunk-Splunk-Enterprise.swidtag’: No such file or directory
complete
#
# ls /opt | grep splunk
splunk
#

②Splunkを起動する

インストール時にはライセンス確認を同意するにしておきます。
ユーザ名は「admin」で設定します。

# /opt/splunk/bin/splunk start --accept-license

This appears to be your first time running this version of Splunk.

Splunk software must create an administrator account during startup. Otherwise, you cannot log in.
Create credentials for the administrator account.
Characters do not appear on the screen when you type in credentials.

Please enter an administrator username:admin
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)

~~~ 省略 ~~~

Done
                                                           [  OK  ]

Waiting for web server at http://127.0.0.1:8000 to be available..... Done


If you get stuck, we're here to help.
Look for answers here: http://docs.splunk.com

The Splunk web interface is at http://xxxxxxxxxxxxx:8000

#

③サーバ起動時にSplunkが自動起動するように設定する

一度Splunkを停止して自動起動設定を入れていきます。

# /opt/splunk/bin/splunk stop
Stopping splunkd...
Shutting down.  Please wait, as this may take a few minutes.
..                                                         [  OK  ]
Stopping splunk helpers...
                                                           [  OK  ]
Done.

# /opt/splunk/bin/splunk enable boot-start
Init script installed at /etc/init.d/splunk.
Init script is configured to run at boot.

④再度Splunkを起動してコマンドで起動確認する

「splunkd is running」となっていれば起動しています。

# /opt/splunk/bin/splunk start

Splunk> CSI: Logfiles.

Checking prerequisites...

~~~ 省略 ~~~

Starting splunk server daemon (splunkd)...
Done
                                                           [  OK  ]

Waiting for web server at http://127.0.0.1:8000 to be available.... Done


If you get stuck, we're here to help.
Look for answers here: http://docs.splunk.com

The Splunk web interface is at http://xxxxxxxxxxxxx:8000

#
# /opt/splunk/bin/splunk status
splunkd is running (PID: 3532).
splunk helpers are running (PIDs: 3538 3554 3650 3717).

⑤SplunkWebへログインする

ブラウザで「http//[ipアドレス]:8000」へアクセスします。
※IPはSplunkをインストールしたサーバのIPアドレス

ログイン画面が表示されたら設定したユーザ名とPWでログインするとTopページが表示されます。

最後に

次回は別サーバでUniversal Forwederを構築してログを飛ばして取り込んでみたいと思います!