From f0a15b48a3170fb0fd5ff7b3c871cbc95ee55550 Mon Sep 17 00:00:00 2001 From: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Date: Mon, 5 Jun 2023 13:58:05 -0400 Subject: [PATCH] Add segment replication cluster-level setting (#4209) * Add segment replication cluster-level setting Signed-off-by: Fanit Kolchina * Moved sections according to use frequency Signed-off-by: Fanit Kolchina * Apply suggestions from code review Co-authored-by: Nathan Bower Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> --------- Signed-off-by: Fanit Kolchina Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Nathan Bower --- .../segment-replication/index.md | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/_tuning-your-cluster/availability-and-recovery/segment-replication/index.md b/_tuning-your-cluster/availability-and-recovery/segment-replication/index.md index 4e2a3ee5..a248670e 100644 --- a/_tuning-your-cluster/availability-and-recovery/segment-replication/index.md +++ b/_tuning-your-cluster/availability-and-recovery/segment-replication/index.md @@ -30,9 +30,13 @@ Segment replication is the first feature in a series of features designed to dec ## Segment replication configuration -To set segment replication as the replication strategy, create an index with replication.type set to `SEGMENT`: +Setting the default replication type for a cluster affects all newly created indexes. However, you can specify a different replication type when creating an index. Index-level settings always override cluster-level settings. -````json +### Creating an index with the segment replication type + +To set segment replication as the replication strategy for an index, create the index with `replication.type` set to `SEGMENT`: + +```json PUT /my-index1 { "settings": { @@ -41,7 +45,7 @@ PUT /my-index1 } } } -```` +``` {% include copy-curl.html %} In segment replication, the primary shard is usually generating more network traffic than the replicas because it copies segment files to the replicas. Thus, it's beneficial to distribute primary shards equally between the nodes. To ensure balanced primary shard distribution, set the dynamic `cluster.routing.allocation.balance.prefer_primary` setting to `true`. For more information, see [Cluster settings]({{site.url}}{{site.baseurl}}/api-reference/cluster-api/cluster-settings/). @@ -65,6 +69,37 @@ curl -X PUT "$host/_cluster/settings?pretty" -H 'Content-Type: application/json' ``` {% include copy-curl.html %} +### Setting the replication type on a cluster + +You can set the default replication type for newly created cluster indexes in the `opensearch.yml` file as follows: + +```yaml +cluster.indices.replication.strategy: 'SEGMENT' +``` +{% include copy.html %} + +This cluster-level setting cannot be enabled through the REST API. +{: .note} + +This setting is not applied to system indexes and hidden indexes. By default, all system and hidden indexes in OpenSearch will still use document replication even if this setting is enabled. +{: .note} + +### Creating an index with the document replication type + +Even when the default replication type is set to segment replication, you can create an index that uses document replication by setting `replication.type` to `DOCUMENT`: + +```json +PUT /my-index1 +{ + "settings": { + "index": { + "replication.type": "DOCUMENT" + } + } +} +``` +{% include copy-curl.html %} + ## Considerations When using segment replication, consider the following: