====== サーバ間の OpenSearch マイグレーション ======
{{indexmenu_n>66}}
===== 概要 =====
The purpose of this topic is to serve as a guide to perform a migration from an OpenSearch server to another OpenSearch server, in the most efficient and simple way possible, copying absolutely everything on the **source** server to be imported into the **target** server.
本トピックは、ある OpenSearch サーバから別の OpenSearch サーバへ移行を行うためのガイドです。**ソース**(移行元)サーバ上のすべてのデータを**ターゲット**(移行先)サーバへインポートし、可能な限り効率的かつ簡潔に移行手順を実行することを目的としています。
**Important points**:
**重要なポイント**:
* Default credentials applied in the automated installation via the online installation script of [[:en:documentation:pandorafms:technical_annexes:38_opensearch_installation|OpenSearch for Pandora FMS]] are indicated (''admin:P4nd0r4!FMS'').
* The name given to the snapshot in the guide is ''migration'', any other can be indicated for better identification if necessary.
* [[:ja:documentation:pandorafms:technical_annexes:38_opensearch_installation|Pandora FMS 用 OpenSearch]] のオンラインインストールスクリプトを使用した自動インストールでは、デフォルトの認証情報(''admin:P4nd0r4!FMS'')が適用されます。
* ガイド内でスナップショットに付けられている名前は ''migration'' ですが、必要に応じて、より識別しやすい別の名前を指定することも可能です。
===== 手順 =====
==== 前提条件 ====
The OpenSearch backup folders must be declared on the servers.
OpenSearch のバックアップフォルダは、サーバ上で定義されている必要があります。
In the ''/etc/opensearch/opensearch.yml'' file, on **both** servers, add this line:
両方のサーバ上の ''/etc/opensearch/opensearch.yml'' ファイルに、次の行を追加します。
path.repo: ["/var/backups/opensearch"]
Restart the OpenSearch service on **both** servers with the following command:
以下のコマンドを使用して、**両方**のサーバで OpenSearch サービスを再起動します。
sudo systemctl restart opensearch
===== フェーズ 1 =====
On the source server, prepare the folder and permissions to host the backup:
ソースサーバ上で、バックアップを格納するためのフォルダとアクセス権限を準備します。
sudo mkdir -p /var/backups/opensearch
sudo rm -rf /var/backups/opensearch/*
sudo chown -R opensearch:opensearch /var/backups/opensearch/
sudo chmod -R 775 /var/backups/opensearch/
An ''rm'' command is executed for security, in case it existed previously (for whatever reason), starting the process with a clean directory.
(何らかの理由で)以前に存在していた場合に備え、セキュリティ上の理由から ''rm'' コマンドが実行され、クリーンなディレクトリの状態でプロセスが開始されます。
Register the repository in OpenSearch. If one was previously created, it is deleted and created again:
OpenSearch にリポジトリを登録します。以前に作成されていた場合は、削除してから再作成します。
# Just in case, we’ll delete the old record from the memory
curl \
-X DELETE \
"https://localhost:9200/_snapshot/migration" -u 'admin:P4nd0r4!FMS' \
-k
# We checked out the repository into the local folder
curl \
-X PUT \
"https://localhost:9200/_snapshot/migration" \
-u 'admin:P4nd0r4!FMS' \
-k \
-H "Content-Type: application/json" \
-d '{
"type": "fs",
"settings": {
"location": "/var/backups/opensearch",
"compress": true
}
}'
In this case, the repository is called ''migration'', as indicated at the beginning of the document.
この場合、ドキュメントの冒頭で示されているように、リポジトリ名は ''migration'' です。
The snapshot is now generated with everything:
スナップショットは、すべての要素を含んだ状態で生成されるようになります。
curl \
-X PUT \
"https://localhost:9200/_snapshot/migration/migration?wait_for_completion=true" \
-u 'admin:P4nd0r4!FMS' \
-k \
-H "Content-Type: application/json" \
-d '{
"indices": "*",
"include_global_state": true
}'
Since ''wait_for_completion=true'' is indicated, the terminal will be stopped and locked until it finishes.
''wait_for_completion=true'' が指定されているため、処理が完了するまで端末は停止し、ロックされます。
Upon completion, the obtained files can be compressed and sent to the target server:
完了後、取得したファイルを圧縮し、ターゲットサーバに送信することができます。
# 1. Check actual size
sudo du -sh /var/backups/opensearch/
# 2. Compress into /tmp
sudo tar -czvf /tmp/opensearch_migration.tar.gz -C /var/backups/opensearch .
# 3. Send to the destination server (replace ‘user’ and the Target Server IP address)
scp /tmp/opensearch_migration.tar.gz user@TARGET_SERVER_IP_ADDRESS:/tmp/
# 1. 実際のサイズを確認
sudo du -sh /var/backups/opensearch/
# 2. /tmp に圧縮
sudo tar -czvf /tmp/opensearch_migration.tar.gz -C /var/backups/opensearch .
# 3. 対象サーバに送信 (‘user’ と対象 IP アドレスは置き換えます)
scp /tmp/opensearch_migration.tar.gz user@TARGET_SERVER_IP_ADDRESS:/tmp/
Alternatively, any other preferred file transfer protocol can be used.
あるいは、その他の任意のファイル転送プロトコルを使用することも可能です。
===== フェーズ 2 =====
If Pandora FMS is running and connected to the target OpenSearch, it must be stopped:
Pandora FMS が稼働しており、対象の OpenSearch に接続されている場合は、停止する必要があります。
sudo systemctl stop pandora_server
Next, unzip the backup and apply the appropriate permissions. If there is already something in the OpenSearch backup folder on the target server (for whatever reason), that content must be deleted first:
次に、バックアップを解凍し、適切な権限を適用します。ターゲットサーバ上の OpenSearch バックアップフォルダに(何らかの理由で)既にファイルなどが存在している場合は、それらを最初に削除する必要があります。
sudo mkdir -p /var/backups/opensearch
sudo rm -rf /var/backups/opensearch/* # Erase, just in case
sudo tar -xzvf /tmp/opensearch_migration.tar.gz -C /var/backups/opensearch/
sudo chown -R opensearch:opensearch /var/backups/opensearch/
sudo chmod -R 755 /var/backups/opensearch/
Next, we will register the repository on the target OpenSearch server:
次に、ターゲットの OpenSearch サーバにリポジトリを登録します。
curl \
-X PUT \
"https://localhost:9200/_snapshot/migration" \
-u 'admin:P4nd0r4!FMS' \
-k \
-H "Content-Type: application/json" \
-d '{
"type": "fs",
"settings": {
"location": "/var/backups/opensearch",
"compress": true
}
}'
And clear the default indexes to avoid any problem:
また、問題を防ぐためにデフォルトのインデックスをクリアします。
curl \
-X DELETE \
"https://localhost:9200/pandorafms-*,"\
".opensearch-observability,"\
".plugins-ml-config,"\
"security-auditlog-*,"\
"top_queries-*,"\
".opensearch-sap-*"\
--cert /etc/opensearch/admin.pem \
--key /etc/opensearch/admin-key.pem \
-k
Finally, the copy made is imported into the new server:
最後に、作成されたコピーを新しいサーバにインポートします。
curl \
-X POST \
"https://localhost:9200/_snapshot/migration/migration/_restore" \
--cert /etc/opensearch/admin.pem \
--key /etc/opensearch/admin-key.pem \
-k \
-H "Content-Type: application/json" \
-d '{
"indices": "*,-.opendistro_security",
"include_global_state": true,
"partial": false
}'
''.opendistro_security'' is omitted to prevent the security plugin from blocking itself.
**You must wait for a response** ''{"accepted":true}''.
''.opendistro_security'' は、セキュリティプラグインがそれ自体をブロックしないように省略されています。
''{"accepted":true}'' という応答を待つ必要があります。
===== フェーズ 3 =====
Verification:
検証:
curl \
-X GET \
"https://localhost:9200/_cat/indices?v" \
--cert /etc/opensearch/admin.pem \
--key /etc/opensearch/admin-key.pem \
-k
And restart the PFMS Server:
そして、PFMS サーバを再起動します。
sudo systemctl start pandora_server
With this process you should have **all** the logs accessible and visible from the PFMS Web Console connected to the target OpenSearch server.
この手順を実行することで、対象の OpenSearch サーバに接続された PFMS Web コンソールから、**すべて**のログにアクセスし、確認できるようになります。
[[ja:documentation:pandorafms:start|Pandora FMS ドキュメント一覧に戻る]]