啟動具有多個主節點的 Amazon EMR 叢集 - Amazon EMR

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

啟動具有多個主節點的 Amazon EMR 叢集

本主題提供啟動具有多個主節點的 Amazon EMR 叢集的組態詳細資訊和範例。

注意

Amazon EMR 會自動為具有多個主節點的所有叢集啟用終止保護,並覆寫您在建立叢集時提供的任何自動終止設定。若要關閉具有多個主節點的叢集,您必須先修改叢集屬性以停用終止保護。如需說明,請參閱 終止具有多個主節點的 Amazon EMR 叢集

先決條件

  • 您可以同時在公有和私有 VPC 子網路中啟動具有多個主節點的 Amazon EMR 叢集。不支援 EC2-Classic。若要在公有子網路中啟動具有多個主節點的 Amazon EMR 叢集,您必須透過在主控台中選取自動指派 IPv4 或執行下列命令,來啟用此子網路中的執行個體以接收公有 IP 地址。請將 22XXXX01 換成您的子網路 ID。

    aws ec2 modify-subnet-attribute --subnet-id subnet-22XXXX01 --map-public-ip-on-launch
  • 若要在具有多個主節點的 Amazon EMR 叢集上執行 Hive、Hue 或 Oozie,您必須建立外部中繼存放區。如需詳細資訊,請參閱設定 Hive 的外部中繼存放區將 Hue 與 Amazon RDS 中的遠端資料庫搭配使用Apache Oozie

  • 若要在叢集中使用 Kerberos 身分驗證,請務必設定外部 KDC。如需詳細資訊,請參閱在 Amazon EMR 上設定 Kerberos

啟動具有多個主節點的 Amazon EMR 叢集

使用執行個體群組或執行個體機群時,可以啟動具有多個主節點的叢集。當您使用具有多個主節點的執行個體群組時,必須為主節點執行個體群組將執行個體計數值指定為 3。當您使用具有多個主節點的執行個體機群時,必須為主執行個體機群將 TargetOnDemandCapacity 指定為 3TargetSpotCapacity 指定為 0,以及針對為主機群設定的每個執行個體類型,將 WeightedCapacity 指定為 1

以下範例示範如何使用預設 AMI 或自訂 AMI 來啟動具有執行個體群組和執行個體機群的叢集:

注意

當您使用 AWS CLI啟動具有多個主節點的 Amazon EMR 叢集時,您必須指定子網路 ID。請使用您的子網路 ID 取代下列範例中的 22XXXX0122XXXX02

Default AMI, instance groups
範例:使用預設 AMI 啟動具有多個主節點的 Amazon EMR 執行個體群組叢集
aws emr create-cluster \ --name "ha-cluster" \ --release-label emr-6.15.0 \ --instance-groups InstanceGroupType=MASTER,InstanceCount=3,InstanceType=m5.xlarge InstanceGroupType=CORE,InstanceCount=4,InstanceType=m5.xlarge \ --ec2-attributes KeyName=ec2_key_pair_name,InstanceProfile=EMR_EC2_DefaultRole,SubnetId=subnet-22XXXX01 \ --service-role EMR_DefaultRole \ --applications Name=Hadoop Name=Spark
Default AMI, instance fleets
範例:使用預設 AMI 啟動具有多個主節點的 Amazon EMR 執行個體機群叢集
aws emr create-cluster \ --name "ha-cluster" \ --release-label emr-6.15.0 \ --instance-fleets '[ { "InstanceFleetType": "MASTER", "TargetOnDemandCapacity": 3, "TargetSpotCapacity": 0, "LaunchSpecifications": { "OnDemandSpecification": { "AllocationStrategy": "lowest-price" } }, "InstanceTypeConfigs": [ { "WeightedCapacity": 1, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.xlarge" }, { "WeightedCapacity": 1, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.2xlarge" }, { "WeightedCapacity": 1, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.4xlarge" } ], "Name": "Master - 1" }, { "InstanceFleetType": "CORE", "TargetOnDemandCapacity": 5, "TargetSpotCapacity": 0, "LaunchSpecifications": { "OnDemandSpecification": { "AllocationStrategy": "lowest-price" } }, "InstanceTypeConfigs": [ { "WeightedCapacity": 1, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.xlarge" }, { "WeightedCapacity": 2, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.2xlarge" }, { "WeightedCapacity": 4, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.4xlarge" } ], "Name": "Core - 2" } ]' \ --ec2-attributes '{"InstanceProfile":"EMR_EC2_DefaultRole","SubnetIds":["subnet-22XXXX01", "subnet-22XXXX02"]}' \ --service-role EMR_DefaultRole \ --applications Name=Hadoop Name=Spark
Custom AMI, instance groups
範例:使用自訂 AMI 啟動具有多個主節點的 Amazon EMR 執行個體群組叢集
aws emr create-cluster \ --name "custom-ami-ha-cluster" \ --release-label emr-6.15.0 \ --instance-groups InstanceGroupType=MASTER,InstanceCount=3,InstanceType=m5.xlarge InstanceGroupType=CORE,InstanceCount=4,InstanceType=m5.xlarge \ --ec2-attributes KeyName=ec2_key_pair_name,InstanceProfile=EMR_EC2_DefaultRole,SubnetId=subnet-22XXXX01 \ --service-role EMR_DefaultRole \ --applications Name=Hadoop Name=Spark \ --custom-ami-id ami-MyAmiID
Custom AMI, instance fleets
範例:使用自訂 AMI 啟動具有多個主節點的 Amazon EMR 執行個體機群叢集
aws emr create-cluster \ --name "ha-cluster" \ --release-label emr-6.15.0 \ --instance-fleets '[ { "InstanceFleetType": "MASTER", "TargetOnDemandCapacity": 3, "TargetSpotCapacity": 0, "LaunchSpecifications": { "OnDemandSpecification": { "AllocationStrategy": "lowest-price" } }, "InstanceTypeConfigs": [ { "WeightedCapacity": 1, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.xlarge" }, { "WeightedCapacity": 1, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.2xlarge" }, { "WeightedCapacity": 1, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.4xlarge" } ], "Name": "Master - 1" }, { "InstanceFleetType": "CORE", "TargetOnDemandCapacity": 5, "TargetSpotCapacity": 0, "LaunchSpecifications": { "OnDemandSpecification": { "AllocationStrategy": "lowest-price" } }, "InstanceTypeConfigs": [ { "WeightedCapacity": 1, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.xlarge" }, { "WeightedCapacity": 2, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.2xlarge" }, { "WeightedCapacity": 4, "BidPriceAsPercentageOfOnDemandPrice": 100, "InstanceType": "m5.4xlarge" } ], "Name": "Core - 2" } ]' \ --ec2-attributes '{"InstanceProfile":"EMR_EC2_DefaultRole","SubnetIds":["subnet-22XXXX01", "subnet-22XXXX02"]}' \ --service-role EMR_DefaultRole \ --applications Name=Hadoop Name=Spark \ --custom-ami-id ami-MyAmiID

終止具有多個主節點的 Amazon EMR 叢集

若要終止具有多個主節點的 Amazon EMR 叢集,您必須在終止該叢集前停用終止保護,如下列範例所示。請將 j-3KVTXXXXXX7UG 換成您的叢集 ID。

aws emr modify-cluster-attributes --cluster-id j-3KVTXXXXXX7UG --no-termination-protected aws emr terminate-clusters --cluster-id j-3KVTXXXXXX7UG