2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Splunk]Splunk Enterpriseの構築(dockerイメージの利用)

Last updated at Posted at 2020-10-08

[Splunk]Splunk Enterpriseの構築(dockerイメージの利用)

目的・背景

Splunkはdockerコンテナでも動作するようです。
コンテナイメージも配布されているようなので、これを利用しSplunkを稼働させてみます。

参考サイト

docker上で「 Splunk 」を動かす
splunk/splunk

docker、docker-composeのインストール

$ sudo apt update

$ sudo apt install -y docker.io
$ docker -v
Docker version 19.03.6, build 369ce74a3c

$ sudo apt install -y docker-compose
$ docker-compose -v
docker-compose version 1.17.1, build unknown

$ sudo groupadd docker
groupadd: group 'docker' already exists
※すでにdockerグループが存在していた

$ sudo gpasswd -a $USER docker
Adding user ubuntu to group docker

$ cat /etc/group | grep docker
docker:x:115:ubuntu

$ sudo reboot

$ docker ps

Splunkコンテナの取得

$ docker pull splunk/splunk
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
splunk/splunk       latest              1d4750df3f5d        3 days ago          1.72GB

Splunkコンテナの作成と起動

$ docker run -d -e "SPLUNK_START_ARGS=--accept-license" -e "SPLUNK_USER=root" -e "SPLUNK_PASSWORD=xxxxxxxx" -p "8000:8000" --name splunk splunk/splunk
$ docker logs splunk -f
    :
PLAY RECAP *********************************************************************
localhost                  : ok=67   changed=8    unreachable=0    failed=0    skipped=65   rescued=0    ignored=0

Tuesday 08 September 2020  05:18:38 +0000 (0:00:00.394)       0:01:26.013 *****
===============================================================================
splunk_common : Update Splunk directory owner -------------------------- 48.08s
splunk_common : Start Splunk via CLI ------------------------------------ 9.35s
splunk_common : Update /opt/splunk/etc ---------------------------------- 2.97s
Gathering Facts --------------------------------------------------------- 2.72s
splunk_common : Get Splunk status --------------------------------------- 2.52s
splunk_common : Wait for splunkd management port ------------------------ 2.15s
splunk_common : Test basic https endpoint ------------------------------- 1.69s
splunk_common : Hash the password --------------------------------------- 1.29s
splunk_common : Trigger restart ----------------------------------------- 0.94s
splunk_common : Get Splunk status --------------------------------------- 0.92s
splunk_common : Generate user-seed.conf (Linux) ------------------------- 0.69s
splunk_common : Check for scloud ---------------------------------------- 0.48s
splunk_common : Find manifests ------------------------------------------ 0.45s
splunk_standalone : Setup global HEC ------------------------------------ 0.45s
splunk_standalone : Get existing HEC token ------------------------------ 0.45s
splunk_common : include_tasks ------------------------------------------- 0.45s
splunk_common : Cleanup Splunk runtime files ---------------------------- 0.42s
Check for required restarts --------------------------------------------- 0.39s
splunk_standalone : Check for required restarts ------------------------- 0.39s
splunk_common : Apply licenses ------------------------------------------ 0.33s
===============================================================================

Ansible playbook complete, will begin streaming splunkd_stderr.log

ここまで表示されたらCTRL+Cでログ参照を中止
ブラウザでhttp://xxx.xxx.xxx.xxx:8000/にアクセス

IDは「admin」、パスワードはコンテナ起動時に指定した「"SPLUNK_PASSWORD=xxxxxxxx"」の値を入力
ダッシュボードが表示されたら起動確認完了

splunkコマンドの実行方法

$ docker exec -it splunk /bin/bash

splunkのインストール先は「/opt/splunk」

$ cd /opt/splunk/bin
$ sudo ./splunk diag
    :
Copying Splunk log files...
Copying bucket info files...
Copying Splunk dispatch files...
Copying Splunk consensus files...
Adding manifest files...
Adding cachemanager_upload.json...
Cleaning up...
Splunk diagnosis file created: /opt/splunk/diag-5d58bc49d37c-2020-09-08_08-04-39.tar.gz

$ exit

コンテナの停止

$ docker stop splunk

コンテナの起動

$ docker start splunk
splunk

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                            PORTS                                                                           NAMES
5d58bc49d37c        splunk/splunk       "/sbin/entrypoint.sh…"   19 minutes ago      Up 3 seconds (health: starting)   8065/tcp, 8088-8089/tcp, 8191/tcp, 9887/tcp, 0.0.0.0:8000->8000/tcp, 9997/tcp   splunk

おわりに

公開されているコンテナイメージを使って起動するのは手動構築するのと同じぐらい簡単です!

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?