graylog 6 インストール手順

環境

CPU 2core
Memory 8GB
Disk 100GB

Rocky Linux 8.10
Graylog 6

手順

実行ユーザーをrootに変更

sudo su

バージョンロック

Graylogはmongodbとopensearchを利用しており、これらのバージョンが指定されているため、基本的にバージョン固定で使用します。
そのため、yumのversionlockをインストールしておきます。

インストール

yum install -y yum-plugin-versionlock

MongoDB

リポジトリファイルを追加

vi /etc/yum.repos.d/mongodb-org.repo
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc

MongoDBインストール

yum install -y mongodb-org

起動確認・設定

systemctl daemon-reload
systemctl enable mongod
systemctl start mongod
systemctl status mongod

バージョンロック

yum versionlock add mongodb-org

OpenSearchインストール

リポジトリファイル作成

curl -SL https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/opensearch-2.x.repo -o /etc/yum.repos.d/opensearch-2.x.repo

GPGチェック無効化

sed -i "s/^gpgcheck=.*/gpgcheck=0/g" /etc/yum.repos.d/opensearch-2.x.repo

インストール

gralogは、opensearch 2.15より新しいバージョンをサポートしていないため、2.15を指定してインストールする。
<custom-admin-password>に適当なパスワードを設定して以下コマンドを実行。

OPENSEARCH_INITIAL_ADMIN_PASSWORD=<custom-admin-password> yum -y install 'opensearch-2.15.0'

バージョンロック

yum versionlock add opensearch.x86_64-2.15

設定

vi /etc/opensearch/opensearch.yml

次のフィールドを変更・追加する

cluster.name: graylog
node.name: ${HOSTNAME}
path.data: /var/lib/opensearch
path.logs: /var/log/opensearch
discovery.type: single-node
network.host: 0.0.0.0
action.auto_create_index: false
plugins.security.disabled: true
indices.query.bool.max_clause_count: 32768

例:

# ======================== OpenSearch Configuration =========================
#
# NOTE: OpenSearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.opensearch.org
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: graylog
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: ${HOSTNAME}
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/opensearch
#
# Path to log files:
#
path.logs: /var/log/opensearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# OpenSearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.type: single-node
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of cluster-manager-eligible nodes:
#
#cluster.initial_cluster_manager_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
action.auto_create_index: false
#action.destructive_requires_name: true
#
# ---------------------------------- Remote Store -----------------------------------
# Controls whether cluster imposes index creation only with remote store enabled
# cluster.remote_store.enabled: true
#
# Repository to use for segment upload while enforcing remote store for an index
# node.attr.remote_store.segment.repository: my-repo-1
#
# Repository to use for translog upload while enforcing remote store for an index
# node.attr.remote_store.translog.repository: my-repo-1
#
# ---------------------------------- Experimental Features -----------------------------------
# Gates the visibility of the experimental segment replication features until they are production ready.
#
#opensearch.experimental.feature.segment_replication_experimental.enabled: false
#
# Gates the functionality of a new parameter to the snapshot restore API
# that allows for creation of a new index type that searches a snapshot
# directly in a remote repository without restoring all index data to disk
# ahead of time.
#
#opensearch.experimental.feature.searchable_snapshot.enabled: false
#
#
# Gates the functionality of enabling extensions to work with OpenSearch.
# This feature enables applications to extend features of OpenSearch outside of
# the core.
#
#opensearch.experimental.feature.extensions.enabled: false
#
#
# Gates the optimization of datetime formatters caching along with change in default datetime formatter
# Once there is no observed impact on performance, this feature flag can be removed.
#
#opensearch.experimental.optimization.datetime_formatter_caching.enabled: false
#
# Gates the functionality of enabling Opensearch to use pluggable caches with respective store names via setting.
#
#opensearch.experimental.feature.pluggable.caching.enabled: false

plugins.security.disabled: true
indices.query.bool.max_clause_count: 32768

JVMオプション

メモリーの半分をXms/Xmxに設定する。
今回は8GBメモリーを搭載しているため、4に設定する。

vi /etc/opensearch/jvm.options

抜粋:

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms4g
-Xmx4g

実行時のカーネルパラメーターを設定

sysctl -w vm.max_map_count=262144
echo 'vm.max_map_count=262144' | tee -a /etc/sysctl.conf

起動

systemctl daemon-reload
systemctl enable opensearch
systemctl start opensearch
systemctl status opensearch

Graylog

リポジトリ登録

rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-6.1-repository_latest.rpm

インストール

yum install graylog-server

バージョンロック

yum versionlock add graylog-server-6.1

password_secret の作成

メモする

< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c${1:-96};echo;

root_password_sha2 の作成

メモする

echo -n "Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1

設定ファイル編集

vi /etc/graylog/server/server.conf

以下の項目を編集

password_secret:メモしたもの
root_password_sha2:メモしたもの
elasticsearch_hosts:http://localhost:9200 (別サーバーにOpenSearchを構築した場合はそのサーバーIP)

password_secret, root_password_sha2

# You MUST set a secret to secure/pepper the stored user passwords here. Use at least 64 characters.
# Generate one by using for example: pwgen -N 1 -s 96
# ATTENTION: This value must be the same on all Graylog nodes in the cluster.
# Changing this value after installation will render all user sessions and encrypted values in the database invalid. (e.g. encrypted access tokens)
password_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

# The default root user is named 'admin'
#root_username = admin

# You MUST specify a hash password for the root user (which you only need to initially set up the
# system and in case you lose connectivity to your authentication backend)
# This password cannot be changed using the API or via the web interface. If you need to change it,
# modify it in this file.
# Create one by using for example: echo -n yourpassword | shasum -a 256
# and put the resulting hash value into the following line
root_password_sha2 = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

elasticsearch_hosts
# List of Elasticsearch hosts Graylog should connect to.
# Need to be specified as a comma-separated list of valid URIs for the http ports of your elasticsearch nodes.
# If one or more of your elasticsearch hosts require authentication, include the credentials in each node URI that
# requires authentication.
#
# Default: http://127.0.0.1:9200
#elasticsearch_hosts = http://node1:9200,http://user:password@node2:9200
elasticsearch_hosts = http://localhost:9200

http_bind_address

sudo sed -i 's/#http_bind_address = 127.0.0.1.*/http_bind_address = 0.0.0.0:9000/g' /etc/graylog/server/server.conf

起動

sudo systemctl daemon-reload
sudo systemctl enable graylog-server.service
sudo systemctl start graylog-server.service
sudo systemctl --type=service --state=active | grep graylog

動作確認

ログイン

http://[サーバーのIPアドレス]:9000/

Username: admin
Password: root_password_sha2 の作成時に設定したパスワード

ログインできれば成功です。

以上

参考

Red Hat Installation with Self-Managed OpenSearch
Install Graylog on Red Hat using self-managed OpenSearch with this guide, covering prerequisites, MongoDB, and Graylog c...

コメント

タイトルとURLをコピーしました