Cross-cluster replication (Public preview)

更新时间:
复制 MD 格式

The Lindorm search engine supports cross-cluster replication for scenarios such as disaster recovery and read/write splitting. This topic describes how to use the cross-cluster replication feature of the Lindorm search engine.

Notes

Cross-cluster replication for the Lindorm search engine is in public preview. To use this feature, you can contact Lindorm technical support on DingTalk (ID: s0s3eg3) to enable it.

Before you begin

  • The search engine version must be 3.10.4 or later.

  • Cross-cluster replication provides the following capabilities:

    • Synchronization between primary and standby clusters: Ensures real-time data synchronization between the primary and standby clusters.

    • Supported write operations on the primary cluster:

      • Batch writes (bulk)

      • Single-document operations (put)

      • Deletions by ID (delete by id)

    • Operations with eventual consistency: Real-time consistency is not guaranteed for the following operations.

      • Updates by ID (update by id)

      • Conditional updates (update by query)

      • Conditional deletions (delete by query)

Cross-cluster replication

Note

You must use the ES API to configure cross-cluster replication. A UI-based configuration method is not yet available.

Create a leader index

You can create a leader index on the primary cluster.

Syntax

PUT /leaderindex

Parameters

Parameter

Description

ccr_mode

Specifies the cross-cluster replication mode.

parallel: Indicates parallel synchronization. The primary cluster uses multiple partitions to synchronize data to the standby cluster.

ccr_id

A custom cluster ID.

Note: For two-way synchronization, the primary and standby clusters must have different IDs to distinguish between their data streams.

Example

curl -XPUT "host:port/leaderindex" -H 'Content-Type: application/json' -d'{
  "settings": {
    "index": {  
          "ccr_mode": "parallel",
          "ccr_id": 1
        }
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "keyword"
      },
      "date": {
        "type": "date"
      }
    }
  }
}'

Create a follow index

You can create a follow index on the standby cluster.

Syntax

PUT /followindex

Parameters

Parameter

Description

ccr_mode

Specifies the cross-cluster replication mode.

parallel: Indicates parallel synchronization. The primary cluster uses multiple partitions to synchronize data to the standby cluster.

ccr_id

A custom cluster ID.

Note: For two-way synchronization, the primary and standby clusters must have different IDs to distinguish between their data streams.

Example

curl -XPUT "host:port/followindex" -H 'Content-Type: application/json' -d'{
  "settings": {
    "index": {  
          "ccr_mode": "parallel",
          "ccr_id": 2
        }
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "keyword"
      },
      "date": {
        "type": "date"
      }
    }
  }
}'

Start data synchronization

You can run a command on the standby cluster to start data synchronization from the leader index to the follow index.

Syntax

POST _plugins/_ccr/followindex/start_follow

Parameters

Parameter

Description

message_cluster

Specifies the address of the message engine.

The built-in message engine is used by default. To find the message_cluster address, run the _ccr/info command on the primary cluster and check the endpoint address in the PRODUCERS section.

leader_index

The leader index on the primary cluster.

Specifies the index on the primary cluster from which the follow index synchronizes data.

Example

curl -XPOST --header 'Content-Type: application/json' -d '{
  "message_cluster" : "ld-txxxx-solr-001.lindorm.rds.aliyuncs.com/172.21.64.28:30080",
  "leader_index" : "leaderindex"
}' 'http://host:port/_plugins/_ccr/followindex/start_follow'

Stop data synchronization

You can run a command on the standby cluster to stop data synchronization from the leader index to the follow index.

Syntax

POST _plugins/_ccr/followindex/stop_follow

Parameters

Parameter

Description

message_cluster

Specifies the address of the message engine.

The built-in message engine is used by default. To find the message_cluster address, run the _ccr/info command on the primary cluster and check the endpoint address in the PRODUCERS section.

leader_index

The leader index on the primary cluster.

Specifies the index on the primary cluster from which the follow index stops synchronizing data.

Example

curl -XPOST "host:port/_plugins/_ccr/followindex/stop_follow" -H 'Content-Type: application/json' -d'{
  "leader_index" : "leaderindex",
  "message_cluster" : "ld-xxx.lindorm.rds.aliyuncs.com/172.xx.xx.xx:30080"
}'

Check link status

After you create the leader and follow indexes, you can run the following command on each cluster to check the status of the active/standby links.

Syntax

GET _plugins/_ccr/info?pretty

Example

curl -XGET host:port/_plugins/_ccr/info?pretty