LoginSignup
0
2

More than 5 years have passed since last update.

AmazonLinux2にGraylog2.4をインストール

Last updated at Posted at 2018-07-30

AmazonLinux2 に Graylog 2.4 をインストールしたのでメモを残しておく

  • AWSでAmazonLinux2 に Graylog 2.4 をインストール
  • ElasticSearchは ElasticSearch Serviceを使う
    • Graylog 2.3からElasticsearch Service が使えるようになった

注意

  • 注意:セキュリティは一切考慮していないので実環境ではちゃんともろもろ設定する

手順

EC2

  • AmazonLinux2 AMIで作成する
  • デフォルト設定だと、 t2.small 以上のインスタンスタイプにしないと、graylog起動した時にメモリ不足で反応しなくなるので注意
  • インスタンスロールで必要なIAM権限をつけておくと、AWS関連のpluginでそのロール使えるのでつけておくと良い

Java

インストール(CentOS installationままでOK)

sudo yum install java-1.8.0-openjdk-headless.x86_64

MongoDB

インストール

/etc/yum.repos.d/mongodb-org-4.0.repo を以下の内容で作成して

[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
sudo yum install -y mongodb-org

起動&有効化

sudo systemctl enable mongod
sudo systemctl start mongod

Elasticsearch

Graylog

インストール(CentOS installationままでOK)

sudo rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-2.4-repository_latest.rpm
sudo yum install graylog-server

設定

http://docs.graylog.org/en/2.4/pages/installation/os/centos.html#graylog
にある通り、 /etc/graylog/server/server.confpassword_secretroot_password_sha2を設定する

また、 elasticsearch_hosts にElastic SearchServiceで作成したクラスタのURLを設定する

起動&有効化

sudo chkconfig --add graylog-server
sudo systemctl daemon-reload
sudo systemctl enable graylog-server.service
sudo systemctl start graylog-server.service

おまけ

デフォルトのタイムゾーン

/etc/graylog/server/server.confroot_timezone で設定できる

JSTにしたいなら

root_timezone = Asia/Tokyo

nginxでproxyさせたい

アクセスログ取りたいとか、アクセス制御したいとかでnginxでproxyしたいことはよくあると思う。

/etc/graylog/server/server.conf で、

web_listen_uri = http://127.0.0.1:9000/

を設定しておいて、、、、

Nginxの設定はこんな感じ

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        server_name  _;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        proxy_set_header    Host    $host;
        proxy_set_header    X-Real-IP    $remote_addr;
        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 //$host/api;

        location / {
            proxy_pass http://localhost:9000;
        }
    }

}

詳しくは http://docs.graylog.org/en/2.4/pages/configuration/web_interface.html#making-the-web-interface-work-with-load-balancers-proxies

ALBでhttps終端したい

ALBでACMの無料証明書でhttps終端したいってことは多々あると思う。

nginxの設定で X-Graylog-Server-URL のprotocolをなしにしておけば、http/httpsどちらでも動くので大丈夫

        proxy_set_header    X-Graylog-Server-URL //$host/api;
0
2
1

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