指定 Amazon EMR 托管的安全组和其它安全组 - Amazon EMR
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

指定 Amazon EMR 托管的安全组和其它安全组

您可以使用 Amazon Web Services Management Console、Amazon CLI 或 Amazon EMR API 指定安全组。如果您未指定安全组,Amazon EMR 会创建默认安全组。指定其它安全组是可选的。您可以为主实例、核心和任务实例和服务访问(仅私有子网)分配其它安全组。

New console
注意

我们重新设计了 Amazon EMR 控制台,以便其易于使用。请参阅 控制台中的新增功能,以了解有关新旧控制台体验差异的信息。

使用新控制台指定安全组
  1. 登录 Amazon Web Services Management Console 并打开 Amazon EMR 控制台,网址为 https://console.aws.amazon.com/emr

  2. 在左侧导航窗格中的 EMR on EC2 下,选择 Clusters(集群),然后选择 Create cluster(创建集群)。

  3. Networking(联网)下,选择 EC2 security groups (firewall) [EC2 安全组(防火墙)] 旁边的箭头以展开此部分。在 Primary node(主节点)和 Core and task nodes(核心节点和任务节点)下,默认选择 Amazon EMR 默认托管安全组。如果您使用私有子网,则还可以选择安全组进行 Service access(服务访问)。

  4. 要更改您的 Amazon EMR 托管安全组,请使用 Choose security groups(选择安全组)下拉菜单以从 Amazon EMR-managed security group(Amazon EMR 托管安全组)选项列表中选择其他选项。您有一个 Amazon EMR 托管安全组,可用于 Primary node(主节点)、Core and task nodes(核心节点和任务节点)。

  5. 要添加自定义安全组,请使用相同的 Choose security groups(选择安全组)下拉菜单从 Custom security group(自定义安全组)选项列表中选择最多四个自定义安全组。对于 Primary node(主节点)和 Core and task nodes(核心节点和任务节点),最多可以有四个自定义安全组。

  6. 选择适用于集群的任何其他选项。

  7. 要启动集群,选择 Create cluster(创建集群)。

Old console
使用旧控制台指定安全组
  1. 导航到 Amazon EMR 新控制台,然后从侧面导航栏中选择切换到旧控制台。有关切换到旧控制台后预期情况的更多信息,请参阅 Using the old console

  2. 依次选择 Create cluster (创建集群)Go to advanced options (转到高级选项)

  3. 选择集群的选项,直到到达 Step 4: Security (步骤 4: 安全组)

  4. 选择 EC2 Security Groups (EC2 安全组) 以展开该部分。

    EMR managed security groups (EMR 托管的安全组) 中,默认情况下选择默认托管安全组。如果 Master(主实例)、Core & Task(核心和任务实例)或 Service Access(服务访问)(仅限私有子网)的 VPC 中不存在默认值,则 Create(创建)会显示在关联的安全组名称之前。

  5. 如果使用自定义托管安全组,请从 EMR managed security groups (EMR 托管的安全组) 列表中进行选择。

    如果您选择自定义托管安全组,将显示一条消息,通知您为其它实例选择自定义安全组。您只能对集群使用自定义或默认托管安全组。

  6. (可选)在 Additional security groups (其它安全组) 下,选择铅笔图标,从列表中最多选择四个安全组,然后选择 Assign security groups (分配安全组)。根据需要对每个 Master (主实例)Core & Task (核心和任务实例)Service Access (服务访问) 重复操作。

  7. 选择创建集群

使用 Amazon CLI 指定安全组

要使用 Amazon CLI 指定安全组,请使用 create-cluster 命令与 --ec2-attributes 选项的以下参数:

参数 描述

EmrManagedPrimarySecurityGroup

使用此参数为主实例指定自定义托管安全组。如果指定此参数,还必须指定 EmrManagedCoreSecurityGroup。对于私有子网中的集群,还必须指定 ServiceAccessSecurityGroup

EmrManagedCoreSecurityGroup

使用此参数为核心和任务实例指定自定义托管安全组。如果指定此参数,还必须指定 EmrManagedPrimarySecurityGroup。对于私有子网中的集群,还必须指定 ServiceAccessSecurityGroup

ServiceAccessSecurityGroup

使用此参数为服务访问指定自定义托管安全组,这仅适用于私有子网中的集群。您指定为 ServiceAccessSecurityGroup 的安全组不应用于任何其它目的,还应为 Amazon EMR 保留。如果指定此参数,还必须指定 EmrManagedPrimarySecurityGroup

AdditionalPrimarySecurityGroups

使用此参数最多为主实例指定四个其它安全组。

AdditionalCoreSecurityGroups

使用此参数最多为核心和任务实例指定四个其它安全组。

例 – 指定自定义 Amazon EMR 托管的安全组和其它安全组

以下示例为私有子网中的集群、主实例的多个其它安全组以及核心和任务实例的单个其它安全组指定自定义 Amazon EMR 托管式安全组。

注意

为了便于读取,包含 Linux 行继续符 (\)。它们可以通过 Linux 命令删除或使用。对于 Windows,请将它们删除或替换为脱字号(^)。

aws emr create-cluster --name "ClusterCustomManagedAndAdditionalSGs" \ --release-label emr-emr-5.36.1 --applications Name=Hue Name=Hive \ Name=Pig --use-default-roles --ec2-attributes \ SubnetIds=subnet-xxxxxxxxxxxx,KeyName=myKey,\ ServiceAccessSecurityGroup=sg-xxxxxxxxxxxx,\ EmrManagedPrimarySecurityGroup=sg-xxxxxxxxxxxx,\ EmrManagedCoreSecurityGroup=sg-xxxxxxxxxxx,\ AdditionalPrimarySecurityGroups=['sg-xxxxxxxxxxx',\ 'sg-xxxxxxxxxxx','sg-xxxxxxxxxx'],\ AdditionalCoreSecurityGroups=sg-xxxxxxxxxxx \ --instance-type m5.xlarge

有关更多信息,请参阅《Amazon CLI 命令参考》中的 create-cluster