

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

# 搭配使用 Amazon S3 on Outposts 和本機 Amazon EMR on Outposts
<a name="s3-outposts-emr"></a>

Amazon EMR 是一種受管叢集平台，可簡化在 上執行大數據架構，例如 Apache Hadoop和 Apache Spark， AWS 以處理和分析大量資料。透過使用這些架構和相關的開放原始碼專案，您可以處理用於分析用途和商業智慧工作負載的資料。Amazon EMR 也可協助您轉換大量資料，並將其移入和移出其他 AWS 資料存放區和資料庫，並支援 Amazon S3 on Outposts。如需 Amazon EMR 的詳細資訊，請參閱《Amazon EMR 管理指南》**中的 [Amazon EMR on Outposts](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-plan-outposts.html)。

對於 Amazon S3 on Outposts，Amazon EMR 7.0.0 版已支援的 Apache Hadoop S3A 連接器。Amazon EMR 的早期版本不支援本機 S3 on Outposts，且不支援 EMR 檔案系統 (EMRFS)。

**支援的應用程式**  
搭配 Amazon S3 on Outposts 的 Amazon EMR 支援下列應用程式：
+ Hadoop
+ Spark
+ Hue
+ Hive
+ Sqoop
+ Pig
+ Hudi
+ Flink

如需詳細資訊，請參閱《[Amazon EMR 版本指南](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-release-components.html)》。

## 建立和設定 Amazon S3 on Outposts 儲存貯體
<a name="create-outposts-bucket"></a>

Amazon EMR 使用 適用於 Java 的 AWS SDK 搭配 Amazon S3 on Outposts 來存放輸入資料和輸出資料。您的 Amazon EMR 日誌檔案會儲存在您選擇的區域 Amazon S3 位置，而不會以本機方式儲存在 Outpost 上。如需詳細資訊，請參閱《Amazon EMR 管理指南》**中的 [Amazon EMR 日誌](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-manage-view-web-log-files.html)。

為了符合 Amazon S3 和 DNS 需求，S3 on Outposts 儲存貯體具有特定的命名約束與限制。如需詳細資訊，請參閱[建立 S3 on Outposts 儲存貯體](S3OutpostsCreateBucket.md)。

使用 Amazon EMR 7.0.0 版及更新版本時，您可以將 Amazon EMR 與 S3 on Outposts 和 S3A 檔案系統搭配使用。

**先決條件**  
**S3 on Outposts 許可** – 當您建立 Amazon EMR 執行個體描述檔時，您的角色必須包含 S3 on Outposts 的 AWS Identity and Access Management (IAM) 命名空間。S3 on Outposts 具有自己的命名空間 `s3-outposts*`。如需有關使用此命名空間的政策範例，請參閱[使用 S3 on Outposts 設定 IAM](S3OutpostsIAM.md)。

**S3A 連接器** – 若要設定 EMR 叢集，以從 Amazon S3 on Outposts 儲存貯體存取資料，您必須使用 Apache Hadoop S3A 連接器。若要使用該連接器，請確保您的所有 S3 URI 均使用 `s3a` 結構描述。如果未使用，您可以設定用於 EMR 叢集的檔案系統實作，以便搭配使用您的 S3 URI 與 S3A 連接器。

若要將檔案系統實作設定為使用 S3A 連接器，您可以使用 EMR 叢集的 `fs.file_scheme.impl` 和 `fs.AbstractFileSystem.file_scheme.impl` 組態屬性，其中 `file_scheme` 對應於您擁有的 S3 URI 類型。若要使用下列範例，請以您自己的資訊取代 *`user input placeholders`*。例如，若要變更使用 `s3` 結構描述之 S3 URI 的檔案系統實作，請指定下列叢集組態屬性：

```
1. [
2.   {
3. "Classification": "core-site",
4.     "Properties": {
5.     "fs.s3.impl": "org.apache.hadoop.fs.s3a.S3AFileSystem",
6.     "fs.AbstractFileSystem.s3.impl": "org.apache.hadoop.fs.s3a.S3A"
7.     }
8.   }
9. ]
```

若要使用 S3A，請將 `fs.file_scheme.impl` 組態屬性設定為 `org.apache.hadoop.fs.s3a.S3AFileSystem`，並將 `fs.AbstractFileSystem.file_scheme.impl` 屬性設定為 `org.apache.hadoop.fs.s3a.S3A`。

例如，如果您存取路徑 `s3a://bucket/...`，請將 `fs.s3a.impl` 屬性設定為 `org.apache.hadoop.fs.s3a.S3AFileSystem`，並將 `fs.AbstractFileSystem.s3a.impl` 屬性設定為 `org.apache.hadoop.fs.s3a.S3A`。

## 搭配使用 Amazon S3 on Outposts 和 Amazon EMR 的入門指引
<a name="getting-started-outposts"></a>

下列主題說明如何開始使用 Amazon EMR 搭配 Amazon S3 on Outposts。

**Topics**
+ [建立許可政策](#create-permission-policy)
+ [建立和設定叢集](#configure-cluster)
+ [組態概觀](#configurations-overview)
+ [考量事項](#considerations)

### 建立許可政策
<a name="create-permission-policy"></a>

在建立使用 Amazon S3 on Outposts 的 EMR 叢集之前，您必須先建立 IAM 政策以連接至該叢集的 Amazon EC2 執行個體設定檔。政策必須具有存取 S3 on Outposts 存取點 Amazon Resource Name (ARN) 的許可。如需有關為 S3 on Outposts 建立 IAM 政策的詳細資訊，請參閱[使用 S3 on Outposts 設定 IAM](S3OutpostsIAM.md)。

下列政策範例會示範如何授予所需的許可。建立政策後，將政策連接至用於建立 EMR 叢集的執行個體設定檔角色，如 [建立和設定叢集](#configure-cluster) 一節中所述。若要使用此範例，請以您自己的資訊取代 *`user input placeholders`*。

```
 1. {
 2. "Version":"2012-10-17",		 	 	  
 3.   "Statement": [
 4.         {
 5.   "Effect": "Allow",
 6.             "Resource": "arn:aws:s3-outposts:us-west-2:111122223333:outpost/op-01ac5d28a6a232904/accesspoint/access-point-name,
 7.             "Action": [
 8.                 "s3-outposts:*"
 9.             ]
10.         }
11.     ]
12.     
13.  }
```

### 建立和設定叢集
<a name="configure-cluster"></a>

若要建立使用 S3 on Outposts 執行 Spark 的叢集，請在主控台中完成下列步驟。

**建立使用 S3 on Outposts 執行 Spark 的叢集**

1. 請在 [https://console.aws.amazon.com/elasticmapreduce/](https://console.aws.amazon.com/elasticmapreduce/) 開啟 Amazon EMR 主控台。

1. 在左側導覽窗格中選擇**叢集**。

1. 選擇 **建立叢集**。

   

1. 針對 **Amazon EMR 版本**，請選擇 **emr-7.0.0** 或更新版本。

1. 針對應用程式套件，請選擇 **Spark 互動式**。然後選取您要包含在叢集上的任何其他支援應用程式。

1. 若要啟用 Amazon S3 on Outposts，請輸入您的組態設定。

**範例組態設定**  
若要使用下列範例組態設定，請以您自己的資訊取代 `user input placeholders`。

   ```
    1. [
    2.  {
    3.    "Classification": "core-site",
    4.    "Properties": {
    5.      "fs.s3a.bucket.DOC-EXAMPLE-BUCKET.accesspoint.arn": "arn:aws:s3-outposts:us-west-2:111122223333:outpost/op-01ac5d28a6a232904/accesspoint/access-point-name"
    6.      "fs.s3a.committer.name": "magic", 
    7.      "fs.s3a.select.enabled": "false"
    8.     }
    9.   },
   10.   {
   11.     "Classification": "hadoop-env",
   12.     "Configurations": [
   13.       {
   14.         "Classification": "export",
   15.         "Properties": {
   16.           "JAVA_HOME": "/usr/lib/jvm/java-11-amazon-corretto.x86_64" 
   17.           }
   18.        }
   19.      ],
   20.      "Properties": {}
   21.    },
   22.    {
   23.      "Classification": "spark-env",
   24.      "Configurations": [
   25.        {
   26.          "Classification": "export",
   27.          "Properties": {
   28.            "JAVA_HOME": "/usr/lib/jvm/java-11-amazon-corretto.x86_64"
   29.          }
   30.        }
   31.       ],
   32.       "Properties": {}
   33.      },
   34.      {
   35.       "Classification": "spark-defaults",
   36.       "Properties": {
   37.         "spark.executorEnv.JAVA_HOME": "/usr/lib/jvm/java-11-amazon-corretto.x86_64",
   38.         "spark.sql.sources.fastS3PartitionDiscovery.enabled": "false"
   39.       }
   40.      }
   41.   ]
   ```

1. 在**聯網**區段中，選擇 AWS Outposts 機架上的虛擬私有雲端 (VPC) 和子網路。如需 Outposts 上的 Amazon EMR 的詳細資訊，請參閱《Amazon EMR 管理指南》**內之 [AWS Outposts上的 EMR 叢集](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-plan-outposts.html)。

1. 在**適用於 Amazon EMR 的 EC2 執行個體設定檔**區段中，選擇連接[您先前建立之許可政策](#create-permission-policy)的 IAM 角色。

1. 設定剩餘的叢集設定，然後選擇**建立叢集**。

### 組態概觀
<a name="configurations-overview"></a>

下表會說明 S3A 組態，以及當您設定使用 S3 on Outposts 搭配 Amazon EMR 的叢集時，要為其參數指定的值。


| 參數 | 預設值 | S3 on Outposts 的必要值 | 說明 | 
| --- | --- | --- | --- | 
|  `fs.s3a.aws.credentials.provider`  |  如果未指定，S3A 會尋找區域儲存貯體 (具有 Outposts 儲存貯體名稱) 中的 S3。  |  S3 on Outposts 儲存貯體的存取點 ARN  |  Amazon S3 on Outposts 支援僅限 虛擬私有雲端 (VPC) 的存取點來作為存取 Outpost 儲存貯體的唯一方法。  | 
|  `fs.s3a.committer.name`  | file |  `magic`  |  Magic Committer 是 S3 on Outposts 唯一支援的遞交程式。  | 
|  `fs.s3a.select.enabled`  |  `TRUE`  |  `FALSE`  | Outposts 上不支援 S3 Select。 | 
|  `JAVA_HOME`  |  `/usr/lib/jvm/java-8`  |  `/usr/lib/jvm/java-11-amazon-corretto.x86_64`  |  S3A 上的 S3 on Outposts 需要 Java 11 版。  | 

下表說明當您設定搭配 Amazon EMR 使用 S3 on Outposts 的叢集時，要為其參數指定的 Spark 組態和值。


| 參數 | 預設值 | S3 on Outposts 的必要值 | 說明 | 
| --- | --- | --- | --- | 
|  `spark.sql.sources.fastS3PartitionDiscovery.enabled`  |  `TRUE`  |  `FALSE`  |  S3 on Outposts 不支援快速分割區。  | 
|  `spark.executorEnv.JAVA_HOME`  |  `/usr/lib/jvm/java-8`  |  `/usr/lib/jvm/java-11-amazon-corretto.x86_64`  |  S3A 上的 S3 on Outposts 需要 Java 11 版。  | 

### 考量事項
<a name="considerations"></a>

當您將 Amazon EMR 與 S3 on Outposts 儲存貯體整合時，請考慮下列事項：
+ Amazon EMR 7.0.0 版及更新版本支援 Amazon S3 on Outposts。
+ 您需要 S3A 連接器才能將 S3 on Outposts 與 Amazon EMR 搭配使用。只有 S3A 具有與 S3 on Outposts 儲存貯體互動所需的功能。如需 S3A 連接器設定資訊，請參閱[先決條件](#s3a-outposts-prerequisites)。
+ Amazon S3 on Outposts 僅支援使用 Amazon S3 受管金鑰 (SSE-S3) 搭配 Amazon EMR 的伺服器端加密。如需詳細資訊，請參閱[S3 on Outposts 中的資料加密](s3-outposts-data-encryption.md)。
+ Amazon S3 on Outposts 不支援使用 S3A FileOutputCommitter 進行寫入。使用 S3 on Outposts 儲存貯體上的 S3A FileOutputCommitter 寫入會導致下列錯誤：InvalidStorageClass: The storage class you specified is not valid。
+ Amazon EMR Serverless 或 Amazon EMR on EKS 不支援 Amazon S3 on Outposts。
+ Amazon EMR 日誌會儲存在您選擇的區域 Amazon S3 位置，而不會以本機方式儲存在 S3 on Outposts 儲存貯體中。