このブログの目的
本記事では、Elastic Certified Engineer試験の出題範囲である以下二つの対策として、Cross-Cluster Search(CCS)とCross-Cluster Replication(CCR)の基本的な仕組みと操作方法を学習します。
Cluster Management – Configure a cluster for cross-cluster search
Cluster Management – Implement cross-cluster replication
まず、CCSやCCRの前提となるRemote Clusterの登録・確認・削除方法を学習し、その後、CCSによるRemote Clusterの検索方法、CCRによるFollower Indexの作成・確認・停止・再開・削除までを順を追って解説します。
実際のKibana画面やREST APIを用いて操作手順を確認しながら学習を進めることで、試験で求められる基本操作を身に付けることを目的としています。
試験情報は以下サイトで確認可能です。
https://www.elastic.co/training/elastic-certified-engineer-exam
Remote Cluster

本章では、Cross-Cluster Search(CCS)およびCross-Cluster Replication(CCR)の前提となるRemote Clusterについて学習します。
Remote Clusterとは
Remote Clusterとは、別のElasticsearch Clusterを参照先として登録するための機能です。Remote Clusterを設定することで、別Clusterに対して検索を実行するCross-Cluster Search(CCS)や、Indexを複製するCross-Cluster Replication(CCR)が利用できるようになります。
Remote Clusterは、通信先となるClusterの接続情報(HostやPortなど)をElasticsearchへ登録するだけで利用できます。登録されたClusterには任意のAliasを付与し、CCSやCCRではそのAliasを指定してアクセスします。
例えば、Local Clusterからcluster2というAliasでRemote Clusterを登録した場合、CCSではcluster2:blogsのようにRemote Cluster上のIndexを検索できます。また、CCRではcluster2をLeader Clusterとして指定し、そのIndexをFollower Clusterへ複製できます。
本章では、Remote Clusterの登録方法、登録内容の確認方法、不要になった設定の削除方法を学習します。Remote ClusterはCCSおよびCCRの前提となる設定であるため、まずは基本的な構成と設定方法を理解しておきましょう。
Elastic Docs > Deploy and manage > Remote clusters
https://www.elastic.co/docs/deploy-manage/remote-clusters
Remote Clusterの登録
検証環境について
Remote Clusterを登録してCCSやCCRを検証するには、通信元と通信先となる2つのElasticsearch Clusterが必要です。本記事では、2つのClusterが構築済みであることを前提として説明を進めます。
検証環境がまだ用意できていない場合は、別記事「Elastic Certified Engineer Exam対策 – Cross Cluster検証環境の構築」を参照し、あらかじめ2つのElasticsearch Clusterを構築してください。なお、本記事ではRemote Clusterの設定やCCS・CCRの操作に焦点を当てるため、Clusterの構築手順については扱いません。
Remote Clusterは、KibanaまたはAPIから登録できます。本記事ではKibanaを使用して登録します。
Kibanaのメニューから Management → Stack Management → Remote Clusters を開き、Add remote cluster を選択します。続いて、Name、Seed nodes、Node connectionsを設定します。

本記事の検証環境では、次のように登録しています。
| 項目 | 設定値 |
|---|---|
| Name | 0815_cluster2 |
| Seed nodes | host.docker.internal:9305 |
| Node connection | 3 |
登録が完了すると、Remote ClusterがElasticsearchへ登録され、CCSやCCRからAlias(上記だと”0815_cluster2”)を指定して利用できるようになります。例えば、CCSでは0815_cluster2:blogsのようにRemote Cluster上のIndexを検索でき、CCRでは0815_cluster2をLeader ClusterとしてFollower Indexを作成できます。
Remote Clusterの登録が正常に完了したかどうかは、次節で紹介する確認方法により検証します。
KibanaでRemote Clusterを登録する画面で、画面右下のShow requestをクリックすることで、実際に実行されるREST APIを確認できます。Remote Clusterは内部的にはCluster Settings APIによって登録されており、Kibanaを利用しなくても同等の設定をAPIから実行できます。検証環境の構築や設定の自動化を行う際は、APIによる登録方法もあわせて覚えておくと便利です。
PUT _cluster/settings { "persistent": { "cluster": { "remote": { "0815_cluster2": { "skip_unavailable": true, "mode": "sniff", "proxy_address": null, "proxy_socket_connections": null, "server_name": null, "seeds": [ "host.docker.internal:9305" ], "node_connections": 3 } } } } }
登録済みRemote Clusterの確認
Remote Clusterが正常に登録されると、Kibanaの Management → Stack Management → Remote Clusters に登録済みのRemote Clusterが表示されます。ここでは、Nameや接続状態(Connected)、Seed nodesなどを確認できます。
本記事の検証環境では、0815_cluster2という名前でRemote Clusterを登録しています。正常に接続できている場合は、接続状態がConnectedとなり、CCSやCCRで利用できる状態であることを確認できます。
APIから確認する場合は、次のAPIを実行します。
GET /_remote/info実行結果の例を以下に示します。

レスポンスの情報は次のとおりです。
| 項目 | 説明 |
|---|---|
| connected | Remote Clusterへ正常に接続できているか。trueであれば接続成功。 |
| mode | 接続方式。本記事ではsniffモード(※)を使用。 |
| seeds | 登録されているSeed node。 |
| num_nodes_connected | Remote Clusterとの通信に使用しているGateway Node数。 |
| max_connections_per_cluster | 最大接続数。Kibanaで設定したNode connectionsに対応。 |
| initial_connect_timeout | Remote Clusterへの初回接続時に待機する最大時間。この時間内に接続できない場合は接続失敗となる。 |
| skip_unavailable | Remote Clusterへ接続できない場合に検索を継続するかどうか。 |
sniffモードとは
sniffモードは、Remote Clusterへ接続後、Node情報を取得し、Gateway Nodeとの通信を自動的に管理する接続方式です。Node構成が変更されても柔軟に対応できるため、CCSやCCRでは通常こちらが利用されます。接続先を固定したい場合は、Proxyモードを使用します。
connectedがfalseの場合は、Remote Clusterとの通信に失敗しています。Host名やTransport Port(9305)、Remote Cluster側の起動状態などを確認してください。正常に接続できていることを確認したら、次章でCCSおよびCCRを利用できます。
Remote Clusterの削除
不要になったRemote Clusterは、KibanaまたはAPIから削除できます。本記事ではKibanaを使用して削除します。
Kibanaの Management → Stack Management → Remote Clusters を開き、削除したいRemote Cluster(本記事では0815_cluster2)のゴミ箱アイコンをクリックし、Deleteを実行します。

Cross-Cluster Search (CCS)

本章では、Cross-Cluster Search(CCS)の基本的な仕組みと利用方法を学習します。CCSを利用すると、Remote Cluster上のIndexをLocal Clusterから検索できるため、複数のElasticsearch Clusterを横断した検索が可能になります。本章では、基本的な検索方法に加え、複数Clusterの検索や主なオプションについて確認し、Elastic Certified Engineer試験で必要となる操作を習得します。
Elastic Docs > Explore and analyze > Cross-cluster search
https://www.elastic.co/docs/explore-analyze/cross-cluster-search
CCSとは
Cross-Cluster Search(CCS)は、Remote Clusterに存在するIndexを、Local Clusterから検索できる機能です。Remote Clusterへ直接アクセスする必要はなく、検索要求をLocal Clusterへ送信するだけで、Remote Clusterへ自動的に検索が実行され、結果がまとめて返されます。
例えば、Remote Clusterを0815_cluster2という名前で登録している場合、0815_cluster2:blogsのようにRemote Cluster名とIndex名を指定することで、Remote Cluster上のblogs Indexを検索できます。また、Local ClusterとRemote Clusterを同時に検索することも可能であり、複数のClusterに分散したデータを一つの検索結果として取得できます。
CCSはデータを複製することなく検索を実行するため、複数拠点のログ検索や、分析専用Clusterから本番Clusterのデータを検索する用途などで利用されます。なお、検索対象のIndexはRemote Cluster上にそのまま保持されるため、CCRのようにFollower Indexが作成されることはありません。
CCSで検索
CCSでは、検索対象のIndex名の前にRemote Cluster名を付与することで、Remote Cluster上のIndexを検索できます。本記事では、第2章で登録した0815_cluster2をRemote Clusterとして使用し、Remote Clusterに登録されているSample Dataを検索します。
例えば、Remote Cluster上のkibana_sample_data_ecommerceを検索する場合は、次のAPIを実行します。
GET 0815_cluster2:kibana_sample_data_ecommerce/_search
{
"query": {
"match_all": {}
}
}
このAPIを実行すると、検索要求はLocal Clusterから0815_cluster2へ転送され、Remote Cluster上のkibana_sample_data_ecommerceに対して検索が実行されます。取得した検索結果はLocal Clusterへ集約され、通常の_search APIと同じ形式で返されます。
検索対象として指定するのはIndex名だけではなく、Wildcardも利用できます。例えば、0815_cluster2:kibana_sample_data_*と指定すると、Remote Cluster上のkibana_sample_data_で始まるすべてのSample Dataを対象に検索できます。
また、Local ClusterとRemote Clusterを同時に検索することも可能です。例えば、次のAPIではLocal ClusterとRemote Clusterのkibana_sample_data_ecommerceをまとめて検索できます。
GET kibana_sample_data_ecommerce,0815_cluster2:kibana_sample_data_ecommerce/_search
{
"query": {
"match_all": {}
}
}
CCSでは通常のSearch APIと同様に、query、sort、aggregationsなどの機能も利用できます。そのため、検索対象の指定方法以外は通常の検索とほぼ同じ操作で利用できる点が特徴です。
CCSのOption : skip unavailable
CCSで特に理解しておきたいオプションがskip_unavailableです。このオプションは、Remote Clusterへ接続できなかった場合に、検索を継続するかどうかを制御します。skip_unavailableはRemote Clusterの登録時に設定します。
| 設定値 | 動作 |
|---|---|
| true | 接続できないRemote Clusterをスキップし、接続可能なClusterのみを検索します。 |
| false | 接続できないRemote Clusterがある場合、検索全体がエラーとなります。 |
例えば、複数のRemote Clusterを検索している際に、そのうち1つが停止していた場合でも、skip_unavailableがtrueであれば検索は継続され、利用可能なClusterの検索結果のみが返されます。一方、falseの場合は、検索全体が失敗します。
本記事の検証環境ではskip_unavailableをtrueに設定しており、一部のRemote Clusterが利用できない場合でも、CCSによる検索を継続できるようにしています。

Cross-Cluster Replication (CCR)
Cross-Cluster Replication(CCR)は、PlatinumまたはEnterpriseのライセンスで利用できる機能です。Basicライセンスでは利用できず、KibanaのCCR管理画面も表示されません。
本章では、Elastic Certified Engineer試験で求められるCCRの基本的な仕組みや操作方法について解説しますが、実際に検証する場合はPlatinum以上のライセンスが必要です。
Elastic self-managed subscriptions
https://www.elastic.co/subscriptions
本章では、Cross-Cluster Replication(CCR)の基本的な仕組みと利用方法を学習します。CCRを利用すると、Remote Cluster上のIndexをFollower Indexとして別Clusterへ複製し、継続的に同期できます。本章では、Follower Indexの作成方法に加え、Replication状態の確認、一時停止・再開、削除方法について学習し、Elastic Certified Engineer試験で必要となる基本操作を習得します。
Elastic Docs > Deploy and manage > Backup, high availability, and resilience tools > Cross-cluster replication
https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication
Cross-Cluster Replicationとは

Cross-Cluster Replication(CCR)は、Remote Cluster上のIndexを別のElasticsearch Clusterへ複製し、継続的に同期する機能です。複製元のIndexをLeader Index、複製先のIndexをFollower Indexと呼びます。Follower IndexはLeader Indexの変更を継続的に取得し、ほぼリアルタイムにデータが同期されます。
CCRでは、あらかじめRemote Clusterを登録しておくことで、Remote Cluster上のLeader Indexを指定してFollower Indexを作成できます。Follower Indexは読み取り専用であり、Documentの追加・更新・削除はLeader Indexで実行します。Leader Indexに反映された変更は、自動的にFollower Indexへ同期されます。
CCRは、災害対策(Disaster Recovery)や、別拠点へのデータ複製、検索負荷の分散などを目的として利用されます。一方、CCSのようにRemote Cluster上のIndexを直接検索する機能ではなく、複製したFollower Indexに対して検索を実行する点が大きな違いです。
Cross-Cluster Replication 作成
CCRを利用するには、Leader Indexを複製するFollower Indexを作成します。本記事では、第2章で登録したRemote Cluster0815_cluster2上のSample DataをLeader Indexとして使用し、Local ClusterへFollower Indexを作成します。
Follower IndexはKibanaまたはAPIから作成できます。本記事ではKibanaを使用します。
Stack Management > Cross-Cluster Replication 画面で、”Create a follower index” をクリックします。

Remote clusterで”0815_cluster2”を選択、Leader indexでは”blogs”を指定、Follower indexで”replicated_blogs”と入力。”Create”をクリックします。

Show requestで確認できるコマンドは以下です。このAPIでもFollower Indexを作成できますが、試験でAPIを直接記述する問題が出題される可能性は低いと考えられます。Kibanaから作成できるようになっておけば十分です。
PUT /replicated_blogs/_ccr/follow { "remote_cluster": "0815_cluster2", "leader_index": "blogs", "max_read_request_operation_count": 5120, "max_outstanding_read_requests": 12, "max_read_request_size": "32mb", "max_write_request_operation_count": 5120, "max_write_request_size": "9223372036854775807b", "max_outstanding_write_requests": 9, "max_write_buffer_count": 2147483647, "max_write_buffer_size": "512mb", "max_retry_delay": "500ms", "read_poll_timeout": "1m" }(参考) 最小限のコマンド
PUT /replicated_blogs/_ccr/follow { "remote_cluster": "0815_cluster2", "leader_index": "blogs" }Elastic API Docs > Cross-cluster replication > Create a follower
https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ccr-follow
remote clusterがlicenseを保有していない環境の場合、以下のErrorが発生します。
(訳) リモートクラスタ 0815_cluster2 上のインデックス blogs のメタデータを取得できませんでした。理由は、リモートクラスタ 0815_cluster2 が Cross-Cluster Replication(CCR) のライセンスを保有していないためです。
クラスタ 0815_cluster2 の現在のライセンスは Basic であり、このライセンスでは CCRは利用できません。
参照元クラスタ、リモートクラスタともに、PlutinumまたはEnterpriseのライセンスが必要となります。
Createをクリックし、以下のように表示されると成功です。

以下、”Follower indices”タブ画面で、”replicated_blogs” indexを確認できます。

Replication状態の確認
Follower Indexを作成したら、Replicationが正常に動作していることを確認します。CCRでは、Follower IndexがLeader Indexと正常に同期できているかを、KibanaまたはAPIから確認できます。本記事では、KibanaとAPIの両方を紹介します。
Kibanaから確認する場合は、Management → Stack Management → Cross-Cluster Replication を開きます。Follower indicesタブには作成済みのFollower Indexが一覧表示され、Replicationの状態を確認できます。
本記事の検証環境では、replicated_blogsが表示され、StatusがActiveであれば、Leader Indexとの同期が正常に行われていることを示します。

APIから確認する場合は、次のAPIを実行します。
GET /replicated_blogs/_ccr/statsレスポンスには、Follower IndexのReplication状態が表示されます。特に確認しておきたい項目は次のとおりです。

| 項目 | 説明 |
|---|---|
| follower_index | Follower Index名 |
| leader_index | Replication元のLeader Index名 |
| remote_cluster | Leader Indexが存在するRemote Cluster名 |
| status | Replicationの状態 |
| operations_read | Leader Indexから読み取ったOperation数 |
| operations_written | Follower Indexへ反映したOperation数 |
StatusがActiveであれば、Follower IndexはLeader Indexとの同期を継続しています。Leader Indexに更新が行われると、operations_readおよびoperations_writtenの値が増加します。更新がない場合は、これらの値が0のままでも正常です。
Replicationの状態を確認したら、次節では、同期を一時的に停止・再開する方法について学習します。
Replicationの一時停止・再開
CCRでは、Follower IndexとLeader Indexの同期を一時的に停止し、必要に応じて再開できます。メンテナンスや設定変更などで一時的に同期を止めたい場合に利用します。同期を停止しても、Leader Indexのデータが削除されることはありません。再開すると、停止期間中にLeader Indexへ反映された変更を取得し、Follower Indexとの同期が継続されます。
Replicationを一時停止するには、”Follower indices” タブ画面で、”pause replication” を実行するか、あるいは次のAPIを実行します。

POST /replicated_blogs/_ccr/pause_follow
実行後、Follower IndexはLeader Indexへの同期を停止します。Kibanaの Management → Stack Management → Cross-Cluster Replication を開くと、replicated_blogs の Status が Paused と表示され、同期が停止していることを確認できます。

Replicationを再開するには、次のAPIを実行します。
POST /replicated_blogs/_ccr/resume_follow

実行後、Follower Indexは再びLeader Indexとの同期を開始します。Kibana上では Status が Active に戻り、以降の変更内容が継続的にFollower Indexへ反映されます。
一時停止・再開はFollower Indexに対して実行する操作であり、Leader Indexには影響しません。また、Follower Indexは読み取り専用であるため、一時停止中であってもFollower Indexへ直接Documentを追加・更新することはできません。
Follower Indexの削除
Follower Indexが不要になった場合は、Leader IndexとのReplicationを解除した後に削除します。Follower Indexは通常のIndexとは異なり、Replicationが有効な状態では削除できません。そのため、
Replicationの停止 → IndexのClose → Replicationの解除 → Indexの削除
という手順で実施します。
まず、Follower IndexのReplicationを停止します(statusがpauseになります)。
POST /replicated_blogs/_ccr/pause_follow
続いて、Follower IndexをCloseします。
POST /replicated_blogs/_close
その後、Follower Indexを通常のIndexへ変換するため、unfollow APIを実行します。
POST /replicated_blogs/_ccr/unfollow
unfollowが正常に完了すると、replicated_blogsは通常のIndexとなり、Leader Indexとの同期は完全に解除されます。以降はLeader IndexでDocumentを追加・更新しても、Follower Indexへ変更は反映されません。
Follower indicesタブ画面で、unfollowされた”replicated_blogs” indexが表示されていないことを確認できます。

最後に、通常のIndexと同様に削除します。
DELETE /replicated_blogs
削除後は、GET _cat/indices?vまたはKibanaのIndex Management画面から、replicated_blogsが削除されていることを確認してください。

なお、unfollow APIは、Follower IndexがCloseされていない状態では実行できません。Closeせずに実行すると、cannot convert the follower index ... because it has not been closedというエラーが返されます。そのため、必ずCloseしてからunfollowを実行してください。
実践問題
Question 1
Search the remote index kibana_sample_data_ecommerce on the remote cluster 0815_cluster2 and return only documents where customer_gender is MALE.
解答
GET 0815_cluster2:kibana_sample_data_ecommerce/_search
{
"query": {
"term": {
"customer_gender": "MALE"
}
}
}解説
CCSでは、検索対象を**<Remote Cluster名>:<Index名>**の形式で指定します。
本問では、Remote Cluster名が0815_cluster2、Index名がkibana_sample_data_ecommerceであるため、次のように指定します。
0815_cluster2:kibana_sample_data_ecommerce
さらに、customer_genderがMALEのDocumentだけを取得するため、term Queryを使用します。CCSでも、検索対象の指定方法以外は通常のSearch APIと同様にQuery DSLを利用できます。
Question 2
Search both the local index blogs and the remote index blogs on the remote cluster 0815_cluster2, and return only documents where category is Technology.
解答
GET blogs,0815_cluster2:blogs/_search
{
"query": {
"term": {
"category": "Technology"
}
}
}解説
CCSでは、ローカルIndexとRemote Cluster上のIndexを同時に検索できます。
複数の検索対象はカンマ区切りで指定します。
blogs,0815_cluster2:blogs
この例では、
blogs:Local Cluster上のIndex0815_cluster2:blogs:Remote Cluster上のIndex
を同時に検索しています。
検索条件にはterm Queryを使用し、categoryがTechnologyのDocumentのみを取得します。CCSでは検索対象の指定方法のみが通常のSearch APIと異なり、Query DSLは通常の検索と同じように利用できます。
Question 3
Create a follower index named replicated_ecommerce that follows the kibana_sample_data_ecommerce index on the remote cluster 0815_cluster2.
解答
PUT /replicated_ecommerce/_ccr/follow
{
"remote_cluster": "0815_cluster2",
"leader_index": "kibana_sample_data_ecommerce"
}または、kibana上から登録でもOK。
解説
CCRでは、Follower Index名はURLで指定し、複製元となるLeader Indexはリクエストボディ内のleader_indexで指定します。
本問では、
- Follower Index:
replicated_ecommerce - Remote Cluster:
0815_cluster2 - Leader Index:
kibana_sample_data_ecommerce
を指定してFollower Indexを作成します。
試験では、Index名やFollower Index名が変更された問題が出題される可能性がありますが、基本的な操作は同じです。remote_clusterとleader_indexを正しく指定できるようにしておきましょう。
上記コマンドで作成した場合、Kibanaで”show request”を確認すると、以下のコマンドが表示されます。コマンドで指定した値以外のdefault値を確認できます。
PUT /replicated_ecommerce/_ccr/follow
{
"remote_cluster": "0815_cluster2",
"leader_index": "kibana_sample_data_ecommerce",
"max_read_request_operation_count": 5120,
"max_outstanding_read_requests": 12,
"max_read_request_size": "32mb",
"max_write_request_operation_count": 5120,
"max_write_request_size": "9223372036854775807b",
"max_outstanding_write_requests": 9,
"max_write_buffer_count": 2147483647,
"max_write_buffer_size": "512mb",
"max_retry_delay": "500ms",
"read_poll_timeout": "1m"
}Elastic社が提供する無料Hands-on Trainingで理解を深めよう
本記事では、Remote Clusterの登録、Cross-Cluster Search(CCS)、Cross-Cluster Replication(CCR)の基本操作について学習しました。ここまで理解できれば、Elastic Certified Engineer試験で求められるCCSおよびCCRの基本知識は十分に身についています。さらに理解を深めたい場合は、Elastic社が提供している無料のHands-on Trainingも活用してみましょう。
Hands-on Trainingでは、実際にElasticsearchやKibanaを操作しながら、Remote Clusterの設定やCCR、CCSによる検索などを体験できます。GUIとAPIの両方を利用して操作できるため、試験対策だけでなく、実務でCross-Cluster機能を利用する際のイメージも身につきます。
特に、CCRはPlatinum以上のライセンスが必要ですが、Elastic社が提供するHands-on環境では、このようなライセンスが必要な機能も利用できます。そのため、Basicライセンス環境では検証できないCCRについても、実際に手を動かしながら学習でき、Elastic Certified Engineer試験対策としても非常に有効です。
受講にはElastic Cloudのアカウントが必要です。以下のサイトからElastic Cloudのアカウントを作成し、無料のHands-on Trainingを体験してみましょう。本記事で学習した内容を実際に操作しながら復習することで、Cross-Cluster機能への理解をさらに深めることができます。
Elastic Cloud アカウント作成
https://cloud.elastic.co/registration
Elastic Training
https://www.elastic.co/training

Elastic Learning Portal
https://learn.elastic.co/pages/58/home-page

当テーマ該当のトレーニング : Multi Cluster Operations

試験対策ポイント
- 要件に従って、Remote Clusterを登録できること。
試験では、Remote Clusterの登録から出題される可能性があります。ただし、設定項目は少なく、問題文の要件どおりにKibanaから登録できれば十分対応できます。
- Local IndexとRemote Cluster上のIndexを組み合わせた検索を実行できること。
SortやPaginationなどを組み合わせた検索が出題される可能性もあるため、これまで学習した内容と合わせて復習しておくことをおすすめします。
- 要件に沿ったCCRの登録ができること。
CCRはPlutinum以上のライセンスが必要ですので、環境が用意できない場合は、Elastic社のHandson環境を利用して、慣れておきましょう。一方で、CCRの一時停止、停止、再開、削除等が出題される可能性は高くないと考えます。




