在AmazonLinux2上安装Graylog2.4

我在AmazonLinux2上安装了Graylog 2.4,所以在这里留下备忘录。

    • AWSでAmazonLinux2 に Graylog 2.4 をインストール

 

    • ElasticSearchは ElasticSearch Serviceを使う

Graylog 2.3からElasticsearch Service が使えるようになった

留意

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

操作步骤

    基本的には CenetOSの手順 http://docs.graylog.org/en/2.4/pages/installation/os/centos.html でほとんどOK

云服务器

    • AmazonLinux2 AMIで作成する

 

    • デフォルト設定だと、 t2.small 以上のインスタンスタイプにしないと、graylog起動した時にメモリ不足で反応しなくなるので注意

 

    • インスタンスロールで必要なIAM権限をつけておくと、AWS関連のpluginでそのロール使えるのでつけておくと良い

https://github.com/Graylog2/graylog-plugin-aws とか

Java – 将以下内容用中文进行同义转述,只需一种选项:Java

安装(仅需保持CentOS安装不变)

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

請寫下一個以中文為母語的替換版本 :

蒙哥DB

    • MongoDBのドキュメントにAmazonLinux2の手順あり

https://docs.mongodb.com/master/tutorial/install-mongodb-on-amazon/

安装

用以下内容创建/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

    • Amazon Elasticsearch Service を使うので、作成しておく

 

    • versionは 5.5

 

    参考 : http://docs.graylog.org/en/2.4/pages/configuration/elasticsearch.html

Graylog

只需按照原样安装(CentOS安装)即可。

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.confのpassword_secretとroot_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.conf 中的 root_timezone 进行设置。

如果想要更改为JST时区的话,
root_timezone = Asia/Tokyo

我想在nginx上配置代理。

我认为许多人经常希望在需要记录访问日志或进行访问控制时,能够使用nginx进行代理。

在/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的协议设置为空,那么它可以在http或https下工作,所以没问题。

        proxy_set_header    X-Graylog-Server-URL //$host/api;
广告
将在 10 秒后关闭
bannerAds