文書の過去の版を表示しています。
Elastic Search バックアップ
From NG 774 version, Pandora FMS incorporates OpenSearch for logs monitoring, this topic is only valid for version 773 or previous versions.
バージョン NG 774 から、Pandora FMS は ログ 監視用に OpenSearch を組み込んでいます。このトピックはバージョン 773 およびそれ以前のバージョンにのみ有効です。
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 サーバからのデータ移行は比較的迅速です。まず、サーバのデータがバックアップし、後で復元できるようにリポジトリに保存します。
バックアップコピーの作成
The machine to be backed up is called the “source machine” and the machine to be restored is called the “target machine”.
バックアップが行われるマシンは “ソースマシン” と呼ばれ、復元が行われるマシンは “ターゲットマシン” と呼ばれます。
- ソースマシンにて
Modify the configuration file elasticsearch.yml
:
設定ファイル “elasticsearch.yml” を編集します。
vi /etc/elasticsearch/elasticsearch.yml
Add the following line:
次の行を追加します。
path.repo: /usr/local/var/backups/
Create the directory previously added to the configuration file:
設定ファイルに追記したディレクトリを作成します。
mkdir -p /usr/local/var/backups/
Grant read and write permissions to directory and user:
ディレクトリのパーミッションとユーザを設定します。
chmod 700 /usr/local/var/backups chown elasticsearch:elasticsearch /usr/local/var/backups
Restart service:
サービスを再起動します。
/etc/init.d/elasticsearch restart
Make backup:
バックアップを作成します。
curl -XPUT http://localhost:9200/_snapshot/my_backup -d '{"type": "fs", "settings": {"compress": "true", "location": "/usr/local/var/backups/"}}}'
Compress backup:
バックアップを圧縮します。
cd /usr/local/var/ tar -zcvf elastic_backup.tar.gz backups/
From the target machine copy the compressed backup of the source machine.
リストアを行うターゲットマシンへ、ソースマシンのバックアップファイルをコピーします。
scp -P 41122 root@<dir_ip_origin>:/root/elastic_backup.tar.gz /home/user/backup
- 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.
- scp コマンドを利用するには、ソースマシンに ssh サーバがインストールされ、ターゲットマシンに ssh クライアントがインストールされている必要があります。
- インポートするマシンの ElasticSearch のバージョンがデータのエクスポートをサポートしていることが重要です。上記の例では、ターゲットマシンの ElasticSearch はソースマシンと同じもしくはそれ以上のバージョンである必要があります。そうでなければ、最初に ElasticSearch をアップデートする必要があります。
バックアップのリストア
- ターゲットマシンにて
1) ソースマシンでバックアップを作成するときに行ったのと同じように、設定ファイルの “elasticsearch.yml” を編集します。
vi /etc/elasticsearch/elasticsearch.yml
次の行を追加します。
path.repo: /usr/local/var/backups/
2) 設定ファイルに追記したディレクトリを作成します。
mkdir -p /usr/local/var/backups/
3) ディレクトリのパーミッションとユーザを設定します。
chmod 700 /usr/local/var/backups chown elasticsearch:elasticsearch /usr/local/var/backups
4) サービスを再起動します。
/etc/init.d/elasticsearch restart
5) ソースマシンからコピーしたバックアップを展開します。
tar -xzvf /home/user/backup/elastic_backup.tar.gz -C /usr/local/var/backups
6) スナップショットがある場所でリポジトリを作成します。
curl -X PUT "localhost:9200/_snapshot/my_backup" -H 'Content-Type: application/json' -d' { "type": "fs", "settings": { "location": "/usr/local/var/backups" } } '
7) インデックスを閉じます。
curl -XPOST http://localhost:9200/<indexname>-*/_close
アスタリスクは、その名前で始まるすべてのインデックスを示します。
8) バックアップをインポートします。
最初に、バックアップをリポジトリへコピーします。
cp <name of the snapshot.dat> my_backup_location/
大文字を使わずにファイル名を変更します。
mv my_backup_location/<name of snapshot.dat> my_backup_location/snap1
以下が重要です。
curl -X POST "localhost:9200/_snapshot/my_backup/snap1/_restore?wait_for_completion=true"
9) 最後に、インデックスを再度開きます。
curl -XPOST http://localhost:9200/<indexname>-*/_open