

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 Amazon OpenSearch 擷取移轉網域和集合之間的資料
<a name="creating-opensearch-service-pipeline"></a>

您可以使用 OpenSearch Ingestion 管道，在 Amazon OpenSearch Service 網域或 OpenSearch Serverless VPC 集合之間遷移資料。若要這樣做，您可以設定管道，其中將一個網域或集合設定為來源，並將另一個網域或集合設定為目的地。這樣可以有效地將您的資料從一個網域或集合遷移到另一個網域或集合。

若要遷移資料，您必須擁有下列資源：
+ 來源 OpenSearch Service 網域或 OpenSearch Serverless VPC 集合。此網域或集合包含您要遷移的資料。如果您使用的是網域，則必須執行 OpenSearch 1.0 版或更新版本，或 Elasticsearch 7.4 版或更新版本。網域還必須具有授予管道角色適當許可的存取政策。
+ 您要將資料遷移到的個別網域或 VPC 集合。此網域或集合將充當管道*接收器*。
+ OpenSearch Ingestion 將用於讀取和寫入集合或網域的管道角色。您可以在管道組態中包含此角色的 Amazon Resource Name (ARN)。如需詳細資訊，請參閱下列資源：
  + [授予 Amazon OpenSearch Ingestion 管道對網域的存取權](pipeline-domain-access.md)
  + [授予 Amazon OpenSearch Ingestion 管道對集合的存取權](pipeline-collection-access.md)

**Topics**
+ [限制](#Limitations-domain-collection)
+ [OpenSearch Service 做為來源](#opensearch-source)
+ [指定多個 OpenSearch Service 網域目的地](#multiple-domains)
+ [將資料遷移至 OpenSearch Serverless VPC 集合](#pipeline-collection)

## 限制
<a name="Limitations-domain-collection"></a>

當您將 OpenSearch Service 網域或 OpenSearch Serverless 集合指定為目的地時，適用下列限制：
+ 管道無法寫入多個 VPC 網域。
+ 您只能在使用 VPC 存取的 OpenSearch Serverless 集合之間遷移資料。不支援公有集合。
+ 您無法在單一管道組態中指定 VPC 和公有網域的組合。
+ 在單一管道組態中，您最多可以有 20 個非管道接收器。
+ 您可以在單一管道組態 AWS 區域 中指定最多三個不同的目的地。
+ 如果任何目的地停機太久，或佈建的容量不足以接收傳入資料，具有多個目的地的管道可能會隨著時間降低處理速度。

## OpenSearch Service 做為來源
<a name="opensearch-source"></a>

您指定為來源的網域或集合是資料遷移*的來源*。

### 在 IAM 中建立管道角色
<a name="source-IAM"></a>

若要建立 OpenSearch 擷取管道，您必須先建立管道角色，以授予網域或集合之間的讀取和寫入存取權。請依下列步驟操作：

1. 在 IAM 中建立新的許可政策以連接到管道角色。請確定您允許從來源讀取和寫入接收器的許可。如需設定 OpenSearch Service 網域 IAM 管道許可的詳細資訊，請參閱 [授予 Amazon OpenSearch Ingestion 管道對網域的存取權](pipeline-domain-access.md)和 [授予 Amazon OpenSearch Ingestion 管道對集合的存取權](pipeline-collection-access.md)。

1. 在管道角色中指定要從來源讀取的下列許可：

------
#### [ JSON ]

****  

   ```
   {
      "Version":"2012-10-17",		 	 	 
      "Statement":[
         {
            "Effect":"Allow",
            "Action":"es:ESHttpGet",
            "Resource":[
               "arn:aws:es:us-east-1:111122223333:domain/domain-name/",
               "arn:aws:es:us-east-1:111122223333:domain/domain-name/_cat/indices",
               "arn:aws:es:us-east-1:111122223333:domain/domain-name/_search",
               "arn:aws:es:us-east-1:111122223333:domain/domain-name/_search/scroll",
               "arn:aws:es:us-east-1:111122223333:domain/domain-name/*/_search"
            ]
         },
         {
            "Effect":"Allow",
            "Action":"es:ESHttpPost",
            "Resource":[
               "arn:aws:es:us-east-1:111122223333:domain/domain-name/*/_search/point_in_time",
               "arn:aws:es:us-east-1:111122223333:domain/domain-name/*/_search/scroll"
            ]
         },
         {
            "Effect":"Allow",
            "Action":"es:ESHttpDelete",
            "Resource":[
               "arn:aws:es:us-east-1:111122223333:domain/domain-name/_search/point_in_time",
               "arn:aws:es:us-east-1:111122223333:domain/domain-name/_search/scroll"
            ]
         }
      ]
   }
   ```

------

### 建立管道
<a name="create"></a>

將政策連接至管道角色後，請使用 **AWSOpenSearchDataMigrationPipeline** 遷移藍圖來建立管道。此藍圖包含用於在 OpenSearch Service 網域或集合之間遷移資料的預設組態。如需詳細資訊，請參閱[使用藍圖](pipeline-blueprint.md)。

**注意**  
OpenSearch Ingestion 使用您的來源網域版本和分佈來確定要用於遷移的機制。有些版本支援 `point_in_time`選項。OpenSearch Serverless 使用 `search_after`選項，因為它不支援 `point_in_time`或 `scroll`。

新的索引可能正在遷移過程中建立，或者文件可能在遷移過程中更新。因此，您可能需要對網域索引資料執行單次掃描或多次掃描，以挑選新的或更新的資料。

透過在管道組態`interval`中設定 `index_read_count`和 ，指定要執行的掃描數量。下列範例示範如何執行多次掃描：

```
scheduling:
    interval: "PT2H"
    index_read_count: 3
    start_time: "2023-06-02T22:01:30.00Z"
```

OpenSearch Ingestion 使用以下組態，以確保您的資料寫入相同的索引，並維護相同的文件 ID：

```
index: "${getMetadata(\"opensearch-index\")}"
document_id: "${getMetadata(\"opensearch-document_id\")}"
```

## 指定多個 OpenSearch Service 網域目的地
<a name="multiple-domains"></a>

您可以指定多個公有 OpenSearch Service 網域做為資料的目的地。您可以使用此功能來執行條件式路由，或將傳入資料複寫至多個 OpenSearch Service 網域。您最多可以將 10 個不同的公有 OpenSearch Service 網域指定為接收器。

在下列範例中，傳入的資料會以條件路由至不同的 OpenSearch Service 網域：

```
...
  route:
    - 2xx_status: "/response >= 200 and /response < 300"
    - 5xx_status: "/response >= 500 and /response < 600"
  sink:
    - opensearch:
        hosts: [ "https://search-response-2xx.region.es.amazonaws.com" ]
        aws:
          region: "us-east-1"
        index: "response-2xx"
        routes:
          - 2xx_status
    - opensearch:
        hosts: [ "https://search-response-5xx.region.es.amazonaws.com" ]
        aws:
          region: "us-east-1"
        index: "response-5xx"
        routes:
          - 5xx_status
```

## 將資料遷移至 OpenSearch Serverless VPC 集合
<a name="pipeline-collection"></a>

您可以使用 OpenSearch Ingestion 將資料從來源 OpenSearch Service 網域或 OpenSearch Serverless 集合遷移至 VPC 集合目的地。您必須在管道組態中提供網路存取政策。如需將資料擷取至 OpenSearch Serverless VPC 集合的詳細資訊，請參閱 [教學課程：使用 Amazon OpenSearch Ingestion 將資料擷取至集合](osis-serverless-get-started.md)。

**將資料遷移至 VPC 集合**

1. 建立 OpenSearch Serverless 集合。如需說明，請參閱[教學課程：使用 Amazon OpenSearch Ingestion 將資料擷取至集合](osis-serverless-get-started.md)。

1. 為集合建立網路政策，指定對集合端點和儀表板端點的 VPC 存取。如需說明，請參閱[Amazon OpenSearch Serverless 的網路存取](serverless-network.md)。

1. 如果您還沒有管道角色，請建立管道角色。如需說明，請參閱[管道角色](pipeline-security-overview.md#pipeline-security-sink)。

1. 建立管道。如需說明，請參閱[使用藍圖](pipeline-blueprint.md)。