Elasticsearch Serviceの既存indexの更新時のダウンタイムについて

ドキュメントの元ネタであるCSVの更新があった時に既存indexを一度削除して既存indexと同じmappingやsettingでindexを再作成してCSVをドキュメントとしてロードしようと考えているのですが、
このときElasticsearch Service上のインスタンスにダウンタイムを発生させないようにするためには、
deploymentを2つ(稼働用と更新用)用意しておいて、更新用のdeploymentでデプロイをしてから
稼働用のsnapshotメニューのRestore from another DeploymentからRestoreすれば良いのでしょうか?

aliasという機能を使えば実現できそうに見えます。

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#indices-aliases-api-example

利用イメージです。
既存のIndexにaliasをつけておき、普段の検索などはそのaliasに対して行うようにしておきます。

POST /_aliases
{
    "actions" : [
        { "add" : { "index" : "test1", "alias" : "alias1" } }
    ]
}

test1というindexに対して、alias1という名前をつけます。
普段使いの検索はalias1に対して行うようにします。 (例 POST alias1/_search )

indexの作成しなおしが発生し、新しいIndexを作成しおわったら、作成していたaliasに対して、新しいIndexを参照するように設定します。

POST /_aliases
{
    "actions" : [
        { "remove" : { "index" : "test1", "alias" : "alias1" } },
        { "add" : { "index" : "new_test", "alias" : "alias1" } }
    ]
}

alias1に対して、test1が削除され、new_testが設定されます。
alias1/_searchで検索すると、test1ではなく、new_testから検索されます。

このようにすれば、aliasの設定先を切り替えるだけで済むため、ダウンタイムがないかと思います。

ご参考になれば幸いです。

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.