OpenSearch Replication

Setting up and validating OpenSearch cross-cluster replication with curl commands.

1 min read Updated SS

OpenSearch replication is the process of storing the primary node data in other replica nodes to provide high availability and avoid data loss.

Follow the steps below for OpenSearch replication:

Configure the replica nodes to connect to the primary node in the OpenSearch cluster, using the below curl command:

curl -XPUT -k -H 'Content-Type: application/json' -u 'admin:admin' 'https://slave:9200/_cluster
/settings?pretty' -d '
{
"persistent": {
"cluster": {
"remote": {
"my-connection-alias": {
"seeds": ["master:9300"]
}
}
}
}
}'

To set an automatic index replication in OpenSearch, execute the following command:

curl -XPOST -k -H 'Content-Type: application/json' -u 'admin:admin' 'https://slave:9200/_plugins/
_replication/_autofollow?pretty' -d '
{
"leader_alias" : "my-connection-alias",
"name": "<index_pattern>",
"pattern": "<index_pattern>*",
"use_roles":{
"leader_cluster_role": "all_access",
"follower_cluster_role": "all_access"
}
}

Note:

  • leader_alias: the parameter is configured in the previous step.
  • name: the parameter should be unique for each index pattern.

To validate the replication statistics for auto-followed indices in OpenSearch, execute the following command:

curl -XGET -u 'admin:admin' -k 'https://slave:9200/_plugins/_replication/autofollow_stats'

To validate the replication statistics for follower indices in OpenSearch, execute the following command:

curl -XGET -u 'admin:admin' -k 'https://slave:9200/_plugins/_replication/follower_stats'

To validate the replication statistics for leader indices in OpenSearch, execute the following command:

curl -XGET -u 'admin:admin' -k 'https://slave:9200/_plugins/_replication/leader_stats'