Add segment replication cluster-level setting (#4209)

* Add segment replication cluster-level setting

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

* Moved sections according to use frequency

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

* Apply suggestions from code review

Co-authored-by: Nathan Bower <nbower@amazon.com>
Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com>

---------

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>
Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com>
Co-authored-by: Nathan Bower <nbower@amazon.com>
This commit is contained in:
kolchfa-aws 2023-06-05 13:58:05 -04:00 committed by GitHub
parent 6cf9ba89f3
commit f0a15b48a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 3 deletions

View File

@ -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: