2
1

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 5 years have passed since last update.

Oracle Cloud Infrastructure(OCI)にGraylog 3.0をインストールしてみた1

Last updated at Posted at 2019-03-15

はじめに

Oracle Cloud Infrastructure(OCI)のComputeにGraylog 3.0をインストールしてみたので備忘録として記載。

必要作業

Graylogを構築するためには以下の作業が必要。

  1. OS構築
  2. Javaインストール
  3. MongoDBインストール
  4. Elasticsearchインストール
  5. Graylogインストール
  6. NGINXインストール

構築の実施

Oracle Cloud Infrastructure(OCI)のため、使用するOSはOracle Linuxとなる。
そのためInstallマニュアルとしてはCentOSを参考に実施する。
マニュアル

1. OS構築

Oracle Cloud Infrastructure(OCI)のComputeを作成。(詳細は割愛)
一応作成した内容としては以下に簡単に記載。

  • Oracle Linux7.6を使用
  • PublicのSubnetに配置
  • セキュリティは0.0.0.0/0とガバガバ(特に今回は構築の検証のため)
  • Compute上のFirewalldも停止(デフォルトでは有効のため無効にした)

2. Javaインストール

Javaの1.8が必要な模様。特に初期構築時のOSにJavaは入っていないため、マニュアルの通りに実施。

[opc@graylog ~]$ sudo yum install java-1.8.0-openjdk-headless.x86_64

【一部省略】

========================================================================================================================
 Package                               Arch             Version                              Repository            Size
========================================================================================================================
Installing:
 java-1.8.0-openjdk-headless           x86_64           1:1.8.0.201.b09-2.el7_6              ol7_latest            32 M
Installing for dependencies:
 avahi-libs                            x86_64           0.6.31-19.el7                        ol7_latest            61 k
 copy-jdk-configs                      noarch           3.3-10.el7_5                         ol7_latest            21 k
 cups-libs                             x86_64           1:1.6.3-35.el7                       ol7_latest           357 k
 javapackages-tools                    noarch           3.4.1-11.el7                         ol7_latest            72 k
 libjpeg-turbo                         x86_64           1.2.90-6.el7                         ol7_latest           134 k
 libxslt                               x86_64           1.1.28-5.0.1.el7                     ol7_latest           241 k
 lksctp-tools                          x86_64           1.0.17-2.el7                         ol7_latest            87 k
 pcsc-lite-libs                        x86_64           1.8.8-8.el7                          ol7_latest            34 k
 python-javapackages                   noarch           3.4.1-11.el7                         ol7_latest            31 k
 python-lxml                           x86_64           3.2.1-4.el7                          ol7_latest           758 k
 tzdata-java                           noarch           2018i-1.el7                          ol7_latest           187 k

Transaction Summary
========================================================================================================================
Install  1 Package (+11 Dependent packages)

Total download size: 34 M
Installed size: 109 M
Is this ok [y/d/N]: y

【一部省略】

Installed:
  java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-2.el7_6

Dependency Installed:
  avahi-libs.x86_64 0:0.6.31-19.el7                           copy-jdk-configs.noarch 0:3.3-10.el7_5
  cups-libs.x86_64 1:1.6.3-35.el7                             javapackages-tools.noarch 0:3.4.1-11.el7
  libjpeg-turbo.x86_64 0:1.2.90-6.el7                         libxslt.x86_64 0:1.1.28-5.0.1.el7
  lksctp-tools.x86_64 0:1.0.17-2.el7                          pcsc-lite-libs.x86_64 0:1.8.8-8.el7
  python-javapackages.noarch 0:3.4.1-11.el7                   python-lxml.x86_64 0:3.2.1-4.el7
  tzdata-java.noarch 0:2018i-1.el7

Complete!
[opc@graylog ~]$

3. MongoDBインストール

とりあえずはGraylogのマニュアルの通りにインストールしてみることに。

[opc@graylog ~]$ sudo vi /etc/yum.repos.d/mongodb-org-4.0.repo
【以下を記載】
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
【ここまで】

[opc@graylog ~]$ sudo yum install mongodb-org

【一部省略】

========================================================================================================================
 Package                          Arch                 Version                      Repository                     Size
========================================================================================================================
Installing:
 mongodb-org                      x86_64               4.0.6-1.el7                  mongodb-org-4.0               5.8 k
Installing for dependencies:
 mongodb-org-mongos               x86_64               4.0.6-1.el7                  mongodb-org-4.0                12 M
 mongodb-org-server               x86_64               4.0.6-1.el7                  mongodb-org-4.0                21 M
 mongodb-org-shell                x86_64               4.0.6-1.el7                  mongodb-org-4.0                13 M
 mongodb-org-tools                x86_64               4.0.6-1.el7                  mongodb-org-4.0                32 M

Transaction Summary
========================================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 79 M
Installed size: 243 M
Is this ok [y/d/N]: y

【一部省略】

Installed:
  mongodb-org.x86_64 0:4.0.6-1.el7

Dependency Installed:
  mongodb-org-mongos.x86_64 0:4.0.6-1.el7                    mongodb-org-server.x86_64 0:4.0.6-1.el7
  mongodb-org-shell.x86_64 0:4.0.6-1.el7                     mongodb-org-tools.x86_64 0:4.0.6-1.el7

Complete!
[opc@graylog ~]$
[opc@graylog ~]$ sudo systemctl daemon-reload
[opc@graylog ~]$ sudo systemctl enable mongod.service
[opc@graylog ~]$ sudo systemctl start mongod.service
[opc@graylog ~]$ 

4. Elasticsearchインストール

これもマニュアルの通りにインストールを実施。

[opc@graylog ~]$ sudo vi /etc/yum.repos.d/elasticsearch.repo
【以下を記載】
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/oss-6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
【ここまで】

[opc@graylog ~]$ sudo yum install elasticsearch-oss

【一部省略】

========================================================================================================================
 Package                          Arch                  Version                  Repository                        Size
========================================================================================================================
Installing:
 elasticsearch-oss                noarch                6.6.2-1                  elasticsearch-6.x                 33 M

Transaction Summary
========================================================================================================================
Install  1 Package

Total download size: 33 M
Installed size: 37 M
Is this ok [y/d/N]: y

【一部省略】

Installed:
  elasticsearch-oss.noarch 0:6.6.2-1

Complete!
[opc@graylog ~]$
[opc@graylog ~]$ sudo vi /etc/elasticsearch/elasticsearch.yml
【以下の項目を修正または追記】
cluster.name: graylog
action.auto_create_index: false
【ここまで】

[opc@graylog ~]$ sudo systemctl daemon-reload
[opc@graylog ~]$ sudo systemctl enable elasticsearch.service
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.
[opc@graylog ~]$ sudo systemctl restart elasticsearch.service
[opc@graylog ~]$

5. Graylogインストール

これもマニュアルの通りにインストールを実施。

[opc@graylog ~]$ sudo rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-3.0-repository_latest.rpm
Retrieving https://packages.graylog2.org/repo/packages/graylog-3.0-repository_latest.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:graylog-3.0-repository-1-6       ################################# [100%]

[opc@graylog ~]$ 
[opc@graylog ~]$ sudo yum install graylog-server

【一部省略】

========================================================================================================================
 Package                          Arch                     Version                      Repository                 Size
========================================================================================================================
Installing:
 graylog-server                   noarch                   3.0.0-12                     graylog                   105 M

Transaction Summary
========================================================================================================================
Install  1 Package

Total download size: 105 M
Installed size: 105 M
Is this ok [y/d/N]: y

【一部省略】

Installed:
  graylog-server.noarch 0:3.0.0-12

Complete!
[opc@graylog ~]$
[opc@graylog ~]$ pwgen -N 1 -s 96
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[opc@graylog ~]$ 
[opc@graylog ~]$ sudo vi /etc/graylog/server/server.conf
【以下を修正】
password_secret = = さっきの上で作成した内容を記載
【ここまで】
[opc@graylog ~]$ 
[opc@graylog ~]$ echo -n "Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1
Enter Password: ログイン用パスワードを入力
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[opc@graylog ~]$ 
[opc@graylog ~]$ sudo vi /etc/graylog/server/server.conf
【以下を修正】
root_password_sha2 = さっきの上で作成した内容を記載
【ここまで】
[opc@graylog ~]$ 
[opc@graylog ~]$ sudo systemctl daemon-reload
[opc@graylog ~]$ sudo systemctl enable graylog-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/graylog-server.service to /usr/lib/systemd/system/graylog-server.service.
[opc@graylog ~]$ sudo systemctl start graylog-server.service
[opc@graylog ~]$

6. NGINXインストール

まずはLBとか使わない予定でproxy設定する必要があるためwebサーバーを用意。

[opc@graylog ~]$ sudo vi /etc/yum.repos.d/nginx.repo
【以下を追記】
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1
【ここまで】

[opc@graylog ~]$ 
[opc@graylog ~]$ sudo yum install nginx

【省略】

==============================================================================================================================================================================================================
 Package                                      Arch                                          Version                                                        Repository                                    Size
==============================================================================================================================================================================================================
Installing:
 nginx                                        x86_64                                        1:1.15.9-1.el7_4.ngx                                           nginx                                        765 k

Transaction Summary
==============================================================================================================================================================================================================
Install  1 Package

Total download size: 765 k
Installed size: 2.7 M
Is this ok [y/d/N]: y

【省略】

Installed:
  nginx.x86_64 1:1.15.9-1.el7_4.ngx

Complete!
[opc@graylog ~]$ 
[opc@graylog ~]$ sudo systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[opc@graylog ~]$ sudo systemctl start nginx

ここまで実施すると、Public IPでNGINXのWelcomeページにアクセスが可能になる。
この後、リバースプロキシの設定を実施する。

[opc@graylog ~]$ sudo vi /etc/nginx/conf.d/graylog.conf
【以下を追記】
server
{
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    server_name ホスト名またはIPアドレス;

    location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-Host $host;
      proxy_set_header X-Forwarded-Server $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Graylog-Server-URL http://$server_name/;
      proxy_pass       http://127.0.0.1:9000;
    }
}
【ここまで】

[opc@graylog ~]$ 
[opc@graylog ~]$ sudo systemctl restart nginx
[opc@graylog ~]$ 

ここまでで基本的なインストールは完了。

画面確認

http://Public IPアドレス
にアクセスすれば、ログイン画面が確認可能となる。
graylog1.PNG

ユーザー名はadmin、パスワードは設定したパスワードを入力することでサインインが可能になった。
graylog2.PNG

今後は、logの設定等について確認していきたい。

2
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?