将超磁盘附加到 Managed Service for Apache Spark 虚拟机

本页面介绍如何将超磁盘挂接到 Managed Service for Apache Spark 集群中的虚拟机 (VM)。您可以为主节点、主工作器和辅助工作器节点组分别配置磁盘。这些磁盘除了挂接到集群节点的启动磁盘和任何挂接到集群节点的本地 SSD 之外,还挂接到集群节点。

准备工作

  1. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  2. Verify that you have the permissions required to complete this guide.

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Managed Service for Apache Spark API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

所需的角色

您需要拥有某些 IAM 角色才能运行本页中的示例。这些角色可能已获授予,具体取决于组织政策。如需查看角色授予情况,请参阅您是否需要授予角色?

如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限

用户角色

如需获得创建 Managed Service for Apache Spark 集群所需的权限,请让管理员向您授予以下 IAM 角色:

服务账号角色

如需确保 Compute Engine 默认服务账号具有创建 Managed Service for Apache Spark 集群所需的权限,请让您的管理员向 Compute Engine 默认服务账号授予项目的 Dataproc Worker (roles/dataproc.worker) IAM 角色。

磁盘特征

附加磁盘具有以下特征:

  • 生命周期:所挂接磁盘的生命周期与所挂接虚拟机的生命周期一致。Managed Service for Apache Spark 在创建虚拟机时创建磁盘,并在删除虚拟机时删除磁盘。
  • 不可变性:创建集群后,您无法更新附加磁盘的属性,例如大小、IOPS 或吞吐量。
  • 装载和使用:Managed Service for Apache Spark 会将磁盘装载到 /mnt/N,其中 N 是一个正整数(例如 /mnt/1/mnt/2)。HDFS 和临时数据(例如 shuffle 输出)会使用所连接的磁盘,而不是启动永久性磁盘。

磁盘配置

将磁盘挂接到 Managed Service for Apache Spark 集群节点时,您可以指定以下磁盘配置参数:

  • 磁盘类型 - 必需:要挂接到虚拟机实例的磁盘类型。 支持以下超磁盘

    • hyperdisk-balanced
    • hyperdisk-extreme
    • hyperdisk-ml
    • hyperdisk-throughput

    hyperdisk balanced high availability 类型和永久性磁盘无法连接到集群节点。

  • 大小 - 可选:磁盘的大小。该值必须是一个整数,后跟 GB 表示千兆字节,或 TB 表示太字节。例如,10GB 会挂接一个 10 千兆字节的磁盘。如需了解详情,请参阅 Hyperdisk 大小限制

  • IOPs - 可选:表示要为所连接的磁盘预配的 IOPS。此参数用于设置每秒磁盘 I/O 操作次数的上限。如需了解详情,请参阅默认性能级别

  • 吞吐量 - 可选:指示要为所连接的磁盘预配的吞吐量。此参数用于设置吞吐量限制,单位为每秒 MiB。如需了解详情,请参阅默认性能级别

将磁盘挂接到集群

您可以使用 gcloud CLI 或 Dataproc API 在创建 Managed Service for Apache Spark 集群时挂接磁盘,以指定磁盘配置。

gcloud CLI

  • 如需在创建集群时挂接磁盘,请将 --master-attached-disks--worker-attached-disks--secondary-worker-attached-disks 标志与 gcloud dataproc clusters create 命令搭配使用。

  • 每个标志都接受以英文分号分隔的磁盘配置列表。每个磁盘配置都是一个以英文逗号分隔的键值对列表,包含 typesizeiopsthroughput(请参阅磁盘配置)。

示例:以下命令会创建一个集群,并将两个超磁盘挂接到每个主要工作器节点。

gcloud dataproc clusters create CLUSTER_NAME \
    --region=REGION \
    --worker-attached-disks='type=hyperdisk-balanced,size=100GB,iops=5000,throughput=200;type=hyperdisk-throughput,size=9000GB'

API

  • 如需挂接磁盘,请在 masterConfigworkerConfigsecondaryWorkerConfig 实例组的 diskConfig 对象中添加 attachedDiskConfigs 数组。

  • clusters.create API 请求的正文中提供配置。

示例:以下 JSON 代码段显示了一个附加了两个超磁盘的 attachedDiskConfigs 数组:

[
  {
    "diskType": "HYPERDISK_BALANCED",
    "diskSizeGb": 100,
    "provisionedIops": 5000,
    "provisionedThroughput": 200
  },
  {
    "diskType": "HYPERDISK_THROUGHPUT",
    "diskSizeGb": 9000
  }
]