Spec-Zone.ru › Elasticsearch 8
›Elasticsearch Guide [8.17] ›Cross-cluster replication ›Tutorial: Disaster recovery based on uni-directional cross-cluster replication

Failback when clusterA comes back

When clusterA comes back, clusterB becomes the new leader and clusterA becomes the follower.

  1. Set up remote cluster clusterB on clusterA.

    resp = client.cluster.put_settings(
        persistent={
            "cluster": {
                "remote": {
                    "clusterB": {
                        "mode": "proxy",
                        "skip_unavailable": "true",
                        "server_name": "clusterb.es.region-b.gcp.elastic-cloud.com",
                        "proxy_socket_connections": "18",
                        "proxy_address": "clusterb.es.region-b.gcp.elastic-cloud.com:9400"
                    }
                }
            }
        },
    )
    print(resp)
    response = client.cluster.put_settings(
      body: {
        persistent: {
          cluster: {
            remote: {
              "clusterB": {
                mode: 'proxy',
                skip_unavailable: 'true',
                server_name: 'clusterb.es.region-b.gcp.elastic-cloud.com',
                proxy_socket_connections: '18',
                proxy_address: 'clusterb.es.region-b.gcp.elastic-cloud.com:9400'
              }
            }
          }
        }
      }
    )
    puts response
    const response = await client.cluster.putSettings({
      persistent: {
        cluster: {
          remote: {
            clusterB: {
              mode: "proxy",
              skip_unavailable: "true",
              server_name: "clusterb.es.region-b.gcp.elastic-cloud.com",
              proxy_socket_connections: "18",
              proxy_address: "clusterb.es.region-b.gcp.elastic-cloud.com:9400",
            },
          },
        },
      },
    });
    console.log(response);
    ### On clusterA ###
    PUT _cluster/settings
    {
      "persistent": {
        "cluster": {
          "remote": {
            "clusterB": {
              "mode": "proxy",
              "skip_unavailable": "true",
              "server_name": "clusterb.es.region-b.gcp.elastic-cloud.com",
              "proxy_socket_connections": "18",
              "proxy_address": "clusterb.es.region-b.gcp.elastic-cloud.com:9400"
            }
          }
        }
      }
    }
  2. Existing data needs to be discarded before you can turn any index into a follower. Ensure the most up-to-date data is available on clusterB prior to deleting any indices on clusterA.

    resp = client.indices.delete(
        index="kibana_sample_data_ecommerce",
    )
    print(resp)
    response = client.indices.delete(
      index: 'kibana_sample_data_ecommerce'
    )
    puts response
    const response = await client.indices.delete({
      index: "kibana_sample_data_ecommerce",
    });
    console.log(response);
    ### On clusterA ###
    DELETE kibana_sample_data_ecommerce
  3. Create a follower index on clusterA, now following the leader index in clusterB.

    resp = client.ccr.follow(
        index="kibana_sample_data_ecommerce",
        wait_for_active_shards="1",
        remote_cluster="clusterB",
        leader_index="kibana_sample_data_ecommerce2",
    )
    print(resp)
    const response = await client.ccr.follow({
      index: "kibana_sample_data_ecommerce",
      wait_for_active_shards: 1,
      remote_cluster: "clusterB",
      leader_index: "kibana_sample_data_ecommerce2",
    });
    console.log(response);
    ### On clusterA ###
    PUT /kibana_sample_data_ecommerce/_ccr/follow?wait_for_active_shards=1
    {
      "remote_cluster": "clusterB",
      "leader_index": "kibana_sample_data_ecommerce2"
    }
  4. The index on the follower cluster now contains the updated documents.

    resp = client.search(
        index="kibana_sample_data_ecommerce",
        q="kimchy",
    )
    print(resp)
    response = client.search(
      index: 'kibana_sample_data_ecommerce',
      q: 'kimchy'
    )
    puts response
    const response = await client.search({
      index: "kibana_sample_data_ecommerce",
      q: "kimchy",
    });
    console.log(response);
    ### On clusterA ###
    GET kibana_sample_data_ecommerce/_search?q=kimchy

    If a soft delete is merged away before it can be replicated to a follower the following process will fail due to incomplete history on the leader, see index.soft_deletes.retention_lease.period for more details.

© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/_failback_when_clustera_comes_back.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API