ja:documentation:pandorafms:technical_annexes:38_opensearch_installation

OpenSearch のインストールと設定

To configure Pandora FMS with OpenSearch see “Log collection and monitoring”.

OpenSearch を使用した Pandora FMS 設定は、「ログの収集と監視」を参照してください。

It is advisable to distribute Pandora FMS server and OpenSearch on independent servers.

Pandora FMS サーバと OpenSearch を独立したサーバに分散することをお勧めします。

  • Rocky Linux 8 / RHEL 8 / Ubuntu 22.04 (recommended operating systems).
  • Minimum 4 GB RAM (testing, dev), recommended 8 GB of RAM for each OpenSearch instance (minimum base requirements, for each environment and amount of data to be processed and/or stored, the specific requirements must be estimated).
  • Disable SWAP on the node or nodes where OpenSearch is.
  • Minimum 4 CPU cores (minimum base requirements, for each environment and amount of data to be processed and/or stored, the specific requirements must be estimated).
  • 50 GB system storage.
  • 100 GB OpenSearch storage (minimum base requirements, for each environment and amount of data to be processed and/or stored, the specific requirements must be estimated).
  • Connectivity from Pandora FMS Server and Web Console to the OpenSearch API (default port 9200/TCP) and between cluster nodes (default port 9300/TCP).
  • Rocky Linux 8 / RHEL 8 / Ubuntu 22.04 (推奨オペレーティングシステム)
  • 最小 4 GB RAM (テスト、開発)、OpenSearch インスタンスごとに 8 GB の RAM を推奨 (最小基本要件、各環境および処理または保存されるデータ量に応じて、特定の要件を見積もる必要があります)。
  • OpenSearch を動作させるノードでは SWAP を無効にします。
  • 最小 4 つの CPU コア (最小基本要件。各環境および処理または保存されるデータ量に応じて、特定の要件を見積もる必要があります)。
  • 50 GB システムストレージ。
  • 100 GB OpenSearch ストレージ (最小基本要件。各環境および処理または保存されるデータ量に応じて、特定の要件を見積もる必要があります)。
  • Pandora FMS サーバおよび Web コンソールから OpenSearch API (デフォルトポート 9200/TCP) およびクラスタノード間の接続 (デフォルトポート 9300/TCP)。

A single node environment with these features can store up to 1 GB of data per day and store it for 30 days. In the case of requiring greater data resilience, greater data processing and storage, and fault tolerance, the configuration of an OpenSearch cluster will be necessary (with a minimum of 3 nodes to guarantee data integrity). By switching to a cluster environment, it is also possible to distribute the load between the nodes, doubling (in the case of 3 nodes) the processing capacity of the environment. A load balancing system will be necessary (Keepalived, for example) if you want to work with the different nodes simultaneously.

これらの機能を備えた単一ノード環境では、1 日あたり最大 1 GB のデータを保存でき、30 日間保存できます。 より優れたデータ復元力、より優れたデータ処理とストレージ、およびフォールトトレランスが必要な場合は、OpenSearch クラスターの構成が必要になります (データの整合性を保証するには、少なくとも 3 つのノードが必要です)。 クラスタ環境に切り替えることでノード間の負荷分散も可能となり、環境の処理能力は2倍(3ノードの場合)となります。 異なるノードを同時に使用する場合、負荷分散システムが必要になります (Keepalived など)。

Official OpenSearch documentation for installation:

インストールに関する OpenSearch の公式ドキュメント:

https://opensearch.org/docs/latest/install-and-configure/install-opensearch/index /

Before running OpenSearch on your machine, you should disable memory paging and swap on the host to improve performance and increase the number of memory maps available to OpenSearch. See “Important Settings” for more information:

マシン上で OpenSearch を実行する前に、パフォーマンスを向上させ、OpenSearch で使用できるメモリマップの数を増やすために、ホスト上のメモリページングとスワップを無効にする必要があります。 詳細については、“Important Settings” を参照してください。

https://opensearch.org/docs/latest/install-and-configure/install-opensearch/index/#important-settings

  # Disable memory paging and swapping.
sudo swapoff -a

# Edit the sysctl config file that defines the host's max map count.
sudo vi /etc/sysctl.conf

# Set max map count to the recommended value of 262144.
vm.max_map_count=262144

# Reload the kernel parameters.
sudo sysctl -p

For Rocky Linux 8, installation via RPM package is recommended.

Rocky Linux 8 の場合は、RPM パッケージでのインストールをお勧めします。

Package listing: https://opensearch.org/downloads.html

パッケージ一覧: https://opensearch.org/downloads.html

Official installation documentation: https://opensearch.org/docs/latest/install-and-configure/install-opensearch/rpm/

公式インストールドキュメント: https://opensearch.org/docs/latest/install-and-configure/install-opensearch/rpm/

Once OpenSearch is installed, access to OpenSearch must be checked from Pandora FMS. Before performing this test you must configure the node or cluster. For this installation check, execute:

OpenSearch をインストールしたら、Pandora FMS から OpenSearch へのアクセスを確認する必要があります。 このテストを実行する前に、ノードまたはクラスタを設定する必要があります。 このインストールチェックでは、次のコマンドを実行します。

curl -X GET https://<ip_opoensearch_box>:9200 -u 'admin:admin' --insecure

You should get a response similar to:

次のような応答が返ります。

  {
     "name" : "hostname",
     "cluster_name" : "opensearch",
     "cluster_uuid" : "6XNc9m2gTUSIoKDqJit0PA",
     "version" : {
        "distribution" : "opensearch",
        "number" : <version>,
        "build_type" : <build-type>,
        "build_hash" : <build-hash>,
        "build_date" : <build-date>,
        "build_snapshot" : false,
        "lucene_version" : <lucene-version>,
        "minimum_wire_compatibility_version" : "7.10.0",
        "minimum_index_compatibility_version" : "7.0.0"
     },
     "tagline" : "The OpenSearch Project: https://opensearch.org/"
  }

By default, the OpenSearch installation enables SSL, username and password which is a good practice; It is recommended to change the default username and password.

デフォルトでは、OpenSearch のインストールでは SSL、ユーザ名、パスワードが有効になっており、これが推奨事項です。 デフォルトのユーザ名とパスワードを変更することをお勧めします。

First edit the configuration file /etc/opensearch/opensearch.yml and then the OpenSearch service will be restarted.

まず設定ファイル /etc/opensearch/opensearch.yml を編集します。その後、OpenSearch サービスを再起動します

This file contains the configuration of all the parameters of theOpenSearch service; See the official documentation for more information:

このファイルには、OpenSearch サービスのすべてのパラメータ設定が含まれています。 詳細については、公式ドキュメントを参照してください。

https://opensearch.org/docs/latest/install-and-configure/configuration/

Minimum configurations necessary to start the service and its use with Pandora FMS.

サービスを開始して Pandora FMS で使用するために必要な最低限の設定。

  • Port number.
  • ポート番号
# ---------------------------------- 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.
  • Location of stored data and logs:
  • データおよびログの保存場所
# ----------------------------------- 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

It will also be necessary to uncomment and define the following lines:

次の行のコメントを外して定義することも必要になります。

cluster.name: pandorafms
node.name: ${HOSTNAME}
network.host: 0.0.0.0
  • cluster.name: This will be the name that the group or cluster will receive.
  • node.name: To name the node using the ${HOSTNAME} system variable, it will automatically take the name of the host.
  • For network.host the value 0.0.0.0 allows OpenSearch to “listen” on all network interfaces (NIC); To use a specific NIC, enter a corresponding specific value.
  • cluster.name: これは、グループまたはクラスタの名前になります。
  • node.name: ${HOSTNAME} システム変数を使用してノードに名前を付けると、ホストの名前が自動的に取得されます。
  • network.host の値 0.0.0.0 により、OpenSearch はすべてのネットワークインターフェイス (NIC) で待ち受けできます。 特定の NIC を使用するには、対応する特定の値を入力します。

If you work with a single node, add the line to the configuration file to allow the single node to start:

単一ノードを使用する場合は、設定ファイルに次の行を追加して、単一ノードが起動できるようにします。

discovery.type: single-node

In case of working with a cluster you need to complete the discovery.seed_hosts parameter:

クラスターを使用する場合は、discovery.seed_hosts パラメータを設定する必要があります。

discover.seed_hosts : ["ip:port", "ip", "ip"]

In the most recent versions of OpenSearch, memory management of the Java® virtual machine is done automatically and it is recommended to let it be managed this way in production environments, so it is unnecessary to modify the JVM values.

OpenSearch の最新バージョンでは、Java® 仮想マシンのメモリ管理は自動的に行われ、実稼働環境ではこの方法で管理することをお勧めします。そのため、JVM 値を変更する必要はありません。

To start OpenSearch, execute:

OpenSearch を開始するには、次のように実行します。

systemctl start opensearch.service

To restart use restart, to stop stop and status to check the status.

再起動には restart、停止には stop、状態を確認するには status を使用します。

If the service does not start, check the logs located at /var/log/opensearch/ (in this case the file pandorafms.log or the name given to the node).

サービスが開始しない場合は、/var/log/opensearch/ にあるログ (この場合はファイル pandorafms.log またはノードに指定された名前) を確認してください。

Remember that to check the installation and operation of OpenSearch you may run:

OpenSearch のインストールと動作の確認は、次のコマンドで行なえます。

curl -X GET https://<node-ip> -u 'admin:admin' --insecure

To configure an OpenSearch cluster, follow the official documentation:

OpenSearch クラスタを設定するには、公式ドキュメントに従ってください。

https://opensearch.org/blog/optimize-opensearch-index-shard-size/

To change the default password from admin, a series of steps must be followed. The first thing is to export the variable to use the Java® JDK installed by OpenSearch to use any of the tools:

デフォルトのパスワードを admin から変更するには、一連の手順に従う必要があります。 まず、OpenSearch によってインストールされた Java® JDK を使用していずれかのツールを使用できるように変数をエクスポートします。

export OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk

Then, to generate the hashed password to place in the OpenSearch configuration file, the following script is used (replace < password > with the password to use):

次に、ハッシュ化されたパスワードを生成して OpenSearch 設定ファイルに配置するために、次のスクリプトを使用します (< password > を使用するパスワードに置き換えます)。

/usr/share/opensearch/plugins/opensearch-security/tools/hash.sh -p <password>

For example:

例:

Then open the file /etc/opensearch/opensearch-security/internal_users.yml with the text editor vim or nano to modify the password of the required user or users.

次に、テキストエディタ vim または nano でファイル /etc/opensearch/opensearch-security/internal_users.yml を開き、必要なユーザのパスワードを変更します。

It is recommended to leave only the admin user for use with Pandora FMS, it is unnecessary to maintain any other user.

Pandora FMS で使用するために admin ユーザのみを残すことをお勧めします。他のユーザを維持する必要はありません。

Example file:

ファイル例:

To make the changes effective, the following must be executed:

変更を有効にするには、以下を実行する必要があります。

cd /usr/share/opensearch/plugins/opensearch-security/tools
OPENSEARCH_JAVA_HOME=/usr/share/opensearch/jdk ./securityadmin.sh -cd /etc/opensearch/opensearch-security/ -cacert /etc/opensearch/root-ca.pem -cert /etc/opensearch/kirk.pem -key /etc/opensearch/kirk-key.pem -icl -nhnv-t internalusers -icl -nhnv -cacert /etc/opensearch/root-ca.pem -cert /etc/opensearch/kirk.pem -key /etc/opensearch/ kirk-key.pem

A final message Done with success should be displayed; to check the new password (following the previous example with pandora used):

最後のメッセージ Done with success が表示されます。 新しいパスワードを確認するには (pandora を使用した前の例に従って) 次のようにします:

For more information on user management in OpenSearch:

OpenSearch でのユーザ管理の詳細については、以下を参照してください。

To configure Pandora FMS with OpenSearch see the topic “Log collection and monitoring”.

OpenSearch を使用するように Pandora FMS を設定するには、“ログ収集と監視” を参照してください。

Before setting an environment into production, whether it is a single node or a data cluster, it is recommended to apply the corresponding configurations to this node or cluster based on its use. In the case of indexes generated by Pandora FMS, the most effective way to do so is by defining a template to define the configuration of the fields and the stored data.

本番環境に設定する前に、それが単一ノードであってもデータクラスタであっても、その用途に基づいてこのノードまたはクラスタに対応する設定を適用することをお勧めします。 Pandora FMS によって生成されたインデックスの場合、最も効果的な方法は、フィールドと保存されたデータの設定を定義するテンプレートを定義することです。

Templates are configurations that are only applied at the time of index creation. Changing a template will not have any impact on existing indexes.

テンプレートは、インデックスの作成時にのみ適用される設定です。 テンプレートを変更しても、既存のインデックスには影響しません。

To create a basic template, you only need to define the following fields:

基本テンプレートを作成するには、次のフィールドを定義するだけで済みます。

curl -X PUT -ku 'admin:admin' https://<node_ip>:9200/_index_template/pandorafms -H 'Content-Type: application/json' -d'
{
  "index_patterns": [
    "pandorafms*"
  ],
  "template": {
    "aliases": {
      "pandorafms_logs": {}
    },
    "settings": {
      "number_of_shards": 1,
      "auto_expand_replicas" : "0-1",
      "number_of_replicas": "0"
    },
"mappings" : {
     "properties" : {
       "agent_id" : {
         "type" : "long"
       },
       "group_id" : {
         "type" : "long"
       },
       "group_name" : {
         "type" : "text"
       },
       "logcontent" : {
         "type" : "text"
       },
       "source_id" : {
         "type" : "text"
       },
       "suid" : {
         "type" : "text"
       },
       "type" : {
         "type" : "text"
       },
       "utimestamp" : {
         "type" : "long"
       },
       "@timestamp": {
          "type": "date"
        }
     }
   }
}
}
'

Through Pandora FMS (menu) interface you may upload said template:

Pandora FMS (メニュー) インターフェイスを通じて、上記のテンプレートをアップロードできます。

  • PUT _template/<templatename>: In this example PUT _template/pandorafms .
  • PUT _template/<templatename>: この例では、 PUT _template/pandorafms です。

You may also check the templates through Pandora FMS interface itself:

Pandora FMS インターフェイス自体を通じてテンプレートを確認することもできます。

  • GET _template/<templatename>: In this example GET _template/pandorafms .
  • GET _template/<templatename>: この例では、 GET _template/pandorafms です。

To define a multinode template, take into account the following information:

複数ノードテンプレートを定義するには、次の情報を考慮してください。

  • When configuring the template (JSON format), you need to configure as many shards as nodes you have, however to correctly configure the replicas subtract 1 from the number of nodes in the environment.
  • テンプレート (JSON 形式) を設定する場合、存在するノードと同じ数のシャードを設定する必要があります。ただし、レプリカを正しく設定するには、環境内のノードの数から 1 を減算します

For example, in a Pandora FMS environment with 3 nodes configured, when you modify the fields number_of_shards and number_of_replicas it should look like this:

たとえば、3 つのノードが設定された Pandora FMS 環境で、number_of_shards フィールドと number_of_replicas フィールドを変更すると、次のようになります。

{
  "index_patterns": ["pandorafms*"],
  "settings": {
    "number_of_shards": 3,
    "auto_expand_replicas" : "0-1",
    "number_of_replicas" : "2"
  },

From the command line you may list the environment templates by executing:

コマンドラインから次のコマンドを実行して、環境テンプレートを一覧表示できます。

curl -X GET "localhost:9200/_cat/templates/*?v=true&s=name&pretty"

You may also see the details of a template, for example, created for pandorafms by running:

次のコマンドを実行すると、たとえば pandorafms 用に作成されたテンプレートの詳細を確認することもできます。

curl -X GET "localhost:9200/_template/pandorafms*?pretty"

which will return the configuration you defined in JSON format.

これにより、定義した設定が JSON 形式で返されます。

You may perform these operations through Pandora FMS interface:

これらの操作は、Pandora FMS インターフェイスを通じて実行できます。

  • PUT _template/<template_name> {json_data}: It allows you to enter the data of the template to be created.
  • GET _template/><template_name>: It allows you to see the created template.
  • PUT _template/<template_name> {json_data}: 作成するテンプレートのデータを入力します。
  • GET _template/><template_name>: 作成したテンプレートを確認できます。

To configure Pandora FMS with OpenSearch see “Log collection and monitoring”.

OpenSearch を使うように Pandora FMS を設定するには、“ログ収集と監視” を参照してください。

Pandora FMS ドキュメント一覧に戻る

  • ja/documentation/pandorafms/technical_annexes/38_opensearch_installation.txt
  • 最終更新: 2023/12/28 06:02
  • by 127.0.0.1