文書の表示以前のリビジョンバックリンク文書の先頭へ この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。 ====== Elastic Search バックアップとリストア ====== {{indexmenu_n>16}} [[ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]] <WRAP center round info 90%> From NG 774 version, Pandora FMS incorporates [[:en:documentation:pandorafms:technical_annexes:38_opensearch_installation|OpenSearch]] for //log// monitoring, this topic is only valid for version 773 or previous versions. </WRAP> <WRAP center round info 90%> バージョン NG 774 から、Pandora FMS は //ログ// 監視用に [[ja:documentation:pandorafms:technical_annexes:38_opensearch_installation|OpenSearch]] を組み込んでいます。このトピックはバージョン 773 およびそれ以前のバージョンにのみ有効です。 </WRAP> Data migration from an Elasticsearch server using snapshots is relatively quick. First, the server data is backed up and then stored in a repository for later restoration. スナップショットを使用した Elasticsearch サーバからのデータ移行は比較的迅速です。まず、サーバのデータがバックアップし、後で復元できるようにリポジトリに保存します。 <wrap #ks1 /> ===== バックアップコピーの作成 ===== <WRAP center round info 90%> The machine to be backed up is called the "source machine" and the machine to be restored is called the "target machine". </WRAP> <WRAP center round info 90%> バックアップが行われるマシンは "ソースマシン" と呼ばれ、復元が行われるマシンは "ターゲットマシン" と呼ばれます。 </WRAP> * ソースマシンにて Modify the configuration file ''elasticsearch.yml'': 設定ファイル "elasticsearch.yml" を編集します。 <code bash> vi /etc/elasticsearch/elasticsearch.yml </code> Add the following line: 次の行を追加します。 <code> path.repo: /usr/local/var/backups/ </code> Create the directory previously added to the configuration file: 設定ファイルに追記したディレクトリを作成します。 <code bash> mkdir -p /usr/local/var/backups/ </code> Grant read and write permissions to directory and user: ディレクトリのパーミッションとユーザを設定します。 <code bash> chmod 700 /usr/local/var/backups chown elasticsearch:elasticsearch /usr/local/var/backups </code> Restart service: サービスを再起動します。 <code bash> /etc/init.d/elasticsearch restart </code> Make backup: バックアップを作成します。 <code bash> curl -XPUT http://localhost:9200/_snapshot/my_backup -d '{"type": "fs", "settings": {"compress": "true", "location": "/usr/local/var/backups/"}}}' </code> Compress backup: バックアップを圧縮します。 <code bash> cd /usr/local/var/ tar -zcvf elastic_backup.tar.gz backups/ </code> From the target machine copy the compressed backup of the source machine. リストアを行うターゲットマシンへ、ソースマシンのバックアップファイルをコピーします。 <code bash> scp -P 41122 root@<dir_ip_origin>:/root/elastic_backup.tar.gz /home/user/backup </code> <WRAP center round tip 90%> * To use the **scp** command, an SSH server must be installed on the source machine and at least one SSH client must be installed on the target machine. * It is important that the version of Elasticsearch on the target machine is compatible with the data export, i.e. in this case the source machine must have the same or higher version. If not, you must first upgrade Elasticsearch on the target machine. </WRAP> <WRAP center round tip 90%> * **scp** コマンドを利用するには、ソースマシンに ssh サーバがインストールされ、ターゲットマシンに ssh クライアントがインストールされている必要があります。 * インポートするマシンの ElasticSearch のバージョンがデータのエクスポートをサポートしていることが重要です。上記の例では、ターゲットマシンの ElasticSearch はソースマシンと同じもしくはそれ以上のバージョンである必要があります。そうでなければ、最初に ElasticSearch をアップデートする必要があります。 </WRAP> <wrap #ks2 /> ===== バックアップのリストア ===== * **On the target machine** * ターゲットマシンにて Modify the configuration file ''elasticsearch.yml'' in the same way as in [[#ks1|create the backup on the source machine]]: [[#ks1|ソースマシンでバックアップを作成]]するときに行ったのと同じように、設定ファイルの "elasticsearch.yml" を編集します。 <code bash> vi /etc/elasticsearch/elasticsearch.yml </code> Add the following line: 次の行を追加します。 <code> path.repo: /usr/local/var/backups/ </code> Create the directory previously added to the configuration file: 設定ファイルに追記したディレクトリを作成します。 <code bash> mkdir -p /usr/local/var/backups/ </code> Grant read and write permissions to the directory: ディレクトリのパーミッションとユーザを設定します。 <code bash> chmod 700 /usr/local/var/backups chown elasticsearch:elasticsearch /usr/local/var/backups </code> Restart the service: サービスを再起動します。 <code bash> /etc/init.d/elasticsearch restart </code> Unzip the backup imported from the source machine: ソースマシンからコピーしたバックアップを展開します。 <code bash> tar -xzvf /home/user/backup/elastic_backup.tar.gz -C /usr/local/var/backups </code> Create the repositories where the snapshots are located: スナップショットがある場所でリポジトリを作成します。 <code bash> curl -X PUT "localhost:9200/_snapshot/my_backup" -H 'Content-Type: application/json' -d' { "type": "fs", "settings": { "location": "/usr/local/var/backups" } } ' </code> Close the indexes: インデックスを閉じます。 <code bash> curl -XPOST http://localhost:9200/< indexes_names >-*/_close </code> <WRAP center round tip 90%> The asterisk shows all indexes starting with that name, ''< indexes_names >''. </WRAP> <WRAP center round tip 90%> アスタリスクは、その名前 ''< indexes_names >'' で始まるすべてのインデックスを示します。 </WRAP> Import the backup, first copy the backup to the repository: バックアップをリポジトリにインポートします。 <code bash> cp <name_snapshot.dat> my_backup_location/ </code> Rename the file without capital letters: ファイル名を大文字なしに変更します。 <code bash> mv my_backup_location/<name_snapshot.dat> my_backup_location/snap1 </code> Finally, it is imported: インポートされます。 <code bash> curl -X POST "localhost:9200/_snapshot/my_backup/snap1/_restore?wait_for_completion=true" </code> Finally, reopen the indexes: 最後に、インデックスを再度開きます。 <code bash> curl -XPOST http://localhost:9200/< indexes_names >-*/_open </code> [[ja:documentation:start|Pandora FMS ドキュメント一覧に戻る]] CKG Edit ja/documentation/pandorafms/technical_annexes/16_elastic_search_backup.txt 最終更新: 2024/10/11 22:56by junichi