

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

# 使用 Delta Lake 叢集搭配 Spark 和 AWS Glue
<a name="Deltacluster-spark-glue"></a>

若要使用 AWS Glue Catalog 做為 Delta Lake 資料表的中繼存放區，請使用下列步驟建立叢集。如需使用 指定 Delta Lake 分類的資訊 AWS Command Line Interface，請參閱[在建立叢集 AWS Command Line Interface 時使用 提供組態](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-configure-apps-create-cluster.html#emr-configure-apps-create-cluster-cli)，或在[建立叢集時使用 Java 開發套件提供組態](https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-configure-apps-create-cluster.html#emr-configure-apps-create-cluster-sdk)。

**建立 Delta Lake 叢集**

1. 使用下列內容建立檔案 `configurations.json`：

   ```
   [{"Classification":"delta-defaults",  
   "Properties":{"delta.enabled":"true"}},
   {"Classification":"spark-hive-site",
   "Properties":{"hive.metastore.client.factory.class":"com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory"}}]
   ```

1. 使用下列組態建立叢集，並將 **example Amazon S3 bucket path** 和 **subnet ID** 取代為您自己的值。

   ```
   aws emr create-cluster 
       --release-label  emr-6.9.0  
       --applications Name=Spark  
       --configurations file://delta_configurations.json 
       --region us-east-1  
       --name My_Spark_Delta_Cluster  
       --log-uri  s3://amzn-s3-demo-bucket/  
       --instance-type m5.xlarge  
       --instance-count 2   
       --service-role EMR_DefaultRole_V2  
       --ec2-attributes  InstanceProfile=EMR_EC2_DefaultRole,SubnetId=subnet-1234567890abcdef0
   ```