弾性雲からAWS弾性探索への旅行


弾性雲から弾性的な探索データをAWSに移行するときに続くステップを示した.
始めましょう.

The Elastic Cloud supports Major.Minor.Patch (eg: x.y.z) version of Elastic Search, where AWS supports only Major. Minor (eg: x.y).


AWSでターゲットクラスタを構築するときは、ソースクラスタの次の最新のマイナーバージョンを使用してクラスタを作成してください.(ソースクラスタバージョンが7.7.1の場合、ターゲットクラスタバージョンは7.8でなければなりません).
弾性検索は、上のバージョンから下のバージョンへの移行を許しません.
{"error":{"root_cause":[{"type":"snapshot_restore_exception","reason":"[test:cloud-snapshot-2021.06.01-ucssrgkdq9oyci-vbbfyfw/QYwmbA6TTJOXG2T83AtTTw] the snapshot was created with Elasticsearch version
 [7.7.1] which is higher than the version of this node [7.7.0]"}],"type":"snapshot_restore_exception","reason":"[test:cloud-snapshot-2021.06.01-ucssrgkdq9oyci-vbbfyfw/QYwmbA6TTJOXG2T83AtTTw] the snapsh
ot was created with Elasticsearch version [7.7.1] which is higher than the version of this node [7.7.0]"},"status":500}

まず、ESのスナップショット/バックアップを格納するカスタムリポジトリとしてAWSアカウントでS 3バケットを作成します.
あなたは、彼らのサイトで弾性雲の上でカスタム倉庫をセットアップするステップを見つけることができました.したがって、私はここでそれらを記述するつもりはありません.
データ復旧中にコマンドを実行するために使用されるEC 2インスタンスを作成します.( T 2ナノでさえ十分です).
ロール- S 3、役割ES、およびポリシーS 3やポリシーESなどの2つのポリシーなどの2つのロールを作成し、それぞれロールにアタッチします.

政策3
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "s3:ListBucket"
            ],
            "Effect": "Allow",
            "Resource": [ 
 "arn:aws:s3:::<es-snapshot-bucket-name>"
            ]
        },
        {
            "Action": [
                "s3:GetObject",
                "s3:PutObject",
                "s3:DeleteObject"
            ],
            "Effect": "Allow",
            "Resource": [ 
  "arn:aws:s3::: <es-snapshot-bucket-name>/*”
            ]
        }
    ]
}

ポリシーes
{
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": "iam:PassRole",
                "Resource": "arn:aws:iam::<account_id>:role/Role-S3"  
            },
            {
                "Effect": "Allow",
                "Action": "es:ESHttpPut",
                "Resource": [
                         "arn:aws:es:<region>:<account_id>:domain/<es_domain_name>/*"
                  ]
            }
        ]
    }
EC 2インスタンスにロール役割ESを付け、EC 2にログインします.
クラスタの到達可能かどうかをチェックするために、curlコマンドを開始します.
curl <es_endpoint>
EC 2に以下のPython LIBSをインストールします.
$ pip3 install boto3
$ pip3 install requests
$ pip3 install requests_aws4auth
$ pip3 install --upgrade request
与えられたPythonスクリプトをコピーしてペーストし、適切な値を変更してスクリプトを実行します.
このスクリプトはS 3バケツを作成したESクラスタのスナップショットリポジトリとして登録します.
import boto3
import requests
from requests_aws4auth 
import AWS4Auth

host = <es_domain_endpoint/>    # Enter the ES domain endpoint and trailing ‘/’
region = <region>       
service = 'es'

credentials = boto3.Session().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)

# Steps to Register snapshot repository
path = '_snapshot/<repository-name>'   # the ES API endpoint
url = host + path
payload = {
  "type": "s3",
  "settings": {
    "bucket": <es_snapshot_bucket_name>, 
    "region": <region>,  # Specify region for S3 bucket. If the S3 bucket is in the us-east-1 region use endpoint
    "endpoint": "s3.amazonaws.com", 
    "role_arn": "arn:aws:iam::<account_id>:role/Role-S3
  }
}
headers = {"Content-Type": "application/json"}
r = requests.put(url, auth=awsauth, json=payload, headers=headers)
print(r.status_code)
print(r.text)
スクリプトが正常に実行された場合は以下のように出力を出力します.
200
{"acknowledged":true}
スナップショットを一覧表示します.
curl <es_endpoint>/_snapshot/<repository_name>/_all?pretty
スナップショットを復元する
curl -XPOST <es_endpoint>/_snapshot/<repository-name>/<snapshot_name>/_restore
設定でスナップショットから特定のインデックスを復元する
curl -XPOST <es_endpoint>/_snapshot/<repository-name>/<snapshot_name>/_restore -d '{
"indices": "<index_name>",
"index_settings": {
  "index.routing.allocation.require.data": null
  }
}' -H 'Content-Type: application/json'
インデックスをダウンリストします.
curl -XGET <es_endpoint>/_cat/indices
回復が成功した場合は、インデックスを表示することができます.

***キーポイント**

Don't restore the .kibana or system indices. It could throw errors.
Don't delete .kibana index in target cluster when restoring.