您可以通过完成以下任务,将 Hyperdisk Balanced、Hyperdisk Extreme 或 Hyperdisk Throughput 卷与 Compute Engine 实例搭配使用:
- 创建空白的非启动、可用区级 Hyperdisk 卷,并在实例创建期间或之后将其挂接到实例。
- 格式化卷并进行装载,以提供对数据或文件系统的访问权限。
对于 Hyperdisk Balanced 卷,您还可以创建启动磁盘和数据磁盘。
如需了解 Hyperdisk 的一般信息,请参阅关于 Hyperdisk。
如需向实例添加 Hyperdisk Balanced 高可用性磁盘,请按照以下步骤操作:
准备工作
- 在将 Hyperdisk 卷添加到计算实例之前,请查看 Hyperdisk 限制。
-
如果您尚未设置身份验证,请进行设置。身份验证是通过其进行身份验证以访问 Google Cloud 服务和 API 的过程。如需从本地开发环境运行代码或示例,您可以通过选择以下选项之一向 Compute Engine 进行身份验证:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
-
Compute Instance Admin (v1) (
roles/compute.instanceAdmin.v1
) -
如需连接到可以作为服务账号运行的实例:Service Account User (v1) (
roles/iam.serviceAccountUser
) -
为了创建并挂接 Hyperdisk 卷:
- 针对项目的
compute.disks.create
权限 - 针对实例的
compute.instances.attachDisk
权限 -
针对您要挂接到实例的卷的
compute.disks.use
- 针对项目的
-
为了格式化和装载挂接的卷:针对实例的
compute.instances.setMetadata
转到虚拟机实例页面。
点击要在其中添加磁盘的实例的名称。
在虚拟机实例详情页面上,点击修改。
在额外磁盘标题下,点击添加新磁盘。
为磁盘指定一个名称,并视需要添加说明。选择空白磁盘作为磁盘来源类型。
在磁盘设置下,从以下列表中选择磁盘类型。您指定的值必须在支持的值范围内。
- Hyperdisk Balanced。您还可以更改默认磁盘的大小、预配 IOPS 和预配吞吐量设置。
- Hyperdisk Extreme。您还可以更改默认磁盘的大小和预配 IOPS 设置。
- Hyperdisk ML。您还可以更改默认磁盘的大小和预配吞吐量设置。
- Hyperdisk Throughput。您还可以更改默认磁盘大小和预配吞吐量设置。
可选:对于 Hyperdisk Balanced 卷,您可以通过采用多写入者模式创建磁盘来允许将磁盘挂接到多个实例。在访问模式下,选择从多个虚拟机进行读写。
点击保存。
如需将更改应用于实例,请点击保存。
使用
gcloud compute disks create
命令创建 Hyperdisk 卷。gcloud compute disks create DISK_NAME \ --zone=ZONE \ --size=DISK_SIZE \ --type=DISK_TYPE \ --provisioned-iops=IOPS_LIMIT --provisioned-throughput=THROUGHPUT_LIMIT --access-mode=DISK_ACCESS_MODE
替换以下内容:
DISK_NAME
:新磁盘的名称。ZONE
:要在其中创建新磁盘的可用区的名称。DISK_SIZE
:可选:新磁盘的大小。该值必须是一个整数,后跟大小单位(GB 表示吉比字节,或 TB 表示太比字节)。如果未指定大小单位,则使用 100 GB 作为默认值。接受的磁盘大小值包括:- Hyperdisk Balanced:从 4 GiB 到 64 TiB(含边界值),以 1 GiB 为增量。
- Hyperdisk Extreme:从 64 GiB 到 64 TiB(含边界值),以 1 GiB 为增量。
- Hyperdisk ML:从 4 GiB 到 64 TiB(含边界值),以 1 GiB 为增量。
- Hyperdisk Throughput:从 2 TiB 到 32 TiB(含边界值),以 1 GiB 为增量。
DISK_TYPE
:磁盘类型。请使用以下值之一:hyperdisk-balanced
、hyperdisk-extreme
、hyperdisk-ml
或hyperdisk-throughput
IOPS_LIMIT
(可选):对于 Hyperdisk Balanced 磁盘或 Hyperdisk Extreme 磁盘,这是磁盘可处理的每秒 I/O 操作数 (IOPS)。THROUGHPUT_LIMIT
(可选):对于 Hyperdisk Balanced、Hyperdisk ML 或 Hyperdisk Throughput 卷,这是一个整数,表示磁盘可提供的最大吞吐量(以 MiB/秒为单位)。DISK_ACCESS_MODE
(可选):计算实例如何访问磁盘上的数据。支持的值包括:READ_WRITE_SINGLE
,表示从一个实例进行读写访问。 这是默认设置。READ_WRITE_MANY
(仅限 Hyperdisk Balanced 和 Hyperdisk Balanced 高可用性),用于从多个实例进行并发读写访问。READ_ONLY_MANY
(仅限 Hyperdisk ML),用于从多个实例进行并发只读访问。
如需为 Hyperdisk Balanced 高可用性磁盘设置访问模式,请参阅创建区域性磁盘。
可选:使用
gcloud compute disks describe DISK_NAME
命令查看磁盘的说明。创建磁盘后,您可以将磁盘挂接到实例。
使用
disks.insert
方法构建POST
请求以创建可用区级 Hyperdisk。 请求应包含name
、sizeGb
、type
、provisionedIops
和provisionedThroughput
属性。 如需创建一个空白且未格式化的非启动磁盘,请不要为此磁盘指定来源映像或来源快照。POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/disks { "name": "DISK_NAME", "sizeGb": "DISK_SIZE", "type": "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/diskTypes/DISK_TYPE", "provisionedIops": "IOPS_LIMIT", "provisionedThroughput": "THROUGHPUT_LIMIT", "accessMode": "DISK_ACCESS_MODE" }
替换以下内容:
PROJECT_ID
:您的项目 IDZONE
:您的实例和新磁盘所在的可用区DISK_NAME
:新磁盘的名称DISK_SIZE
:可选:新磁盘的大小。该值必须是一个整数,后跟大小单位(GB 表示吉比字节,或 TB 表示太比字节)。DISK_TYPE
:磁盘类型。如需创建 Hyperdisk 卷,请使用以下值之一:hyperdisk-balanced
、hyperdisk-extreme
、hyperdisk-ml
或hyperdisk-throughput
。IOPS_LIMIT
(可选):对于 Hyperdisk Balanced 和 Hyperdisk Extreme,这是磁盘可处理的每秒 I/O 操作数。THROUGHPUT_LIMIT
(可选):对于 Hyperdisk Balanced、Hyperdisk ML 或 Hyperdisk Throughput 卷,这是一个整数,表示磁盘可提供的最大吞吐量(以 MiB/秒为单位)。DISK_ACCESS_MODE
(可选):计算实例如何访问磁盘上的数据。支持的值包括:READ_WRITE_SINGLE
,表示从一个实例进行读写访问。 这是默认设置。READ_WRITE_MANY
(仅适用于 Hyperdisk Balanced 和 Hyperdisk Balanced 高可用性),用于从多个实例进行并发读写访问。READ_ONLY_MANY
(仅限 Hyperdisk ML),用于从多个实例进行并发只读访问。
如需为 Hyperdisk Balanced 高可用性磁盘设置访问模式,请参阅创建区域性磁盘。
可选:使用
compute.disks.get
方法查看磁盘的说明。创建磁盘后,您可以将磁盘挂接到任何正在运行或已停止的实例。
- Linux:请参阅在 Linux 计算实例上格式化和装载非启动磁盘
- Windows:请参阅在 Windows 计算实例上格式化和装载非启动磁盘
- 了解如何自定义 Hyperdisk 卷上的 IOPS 和吞吐量。
- 了解如何定期使用快照备份磁盘,防止意外丢失数据。
Go
如需在本地开发环境中使用本页面上的 Go 示例,请安装并初始化 gcloud CLI,然后使用您的用户凭证设置应用默认凭证。
如需了解详情,请参阅 Set up authentication for a local development environment。 如需了解详情,请参阅身份验证文档中的为本地开发环境设置 ADC。
Java
如需在本地开发环境中使用本页面上的 Java 示例,请安装并初始化 gcloud CLI,然后使用您的用户凭证设置应用默认凭证。
如需了解详情,请参阅 Set up authentication for a local development environment。 如需了解详情,请参阅身份验证文档中的为本地开发环境设置 ADC。
Node.js
如需在本地开发环境中使用本页面上的 Node.js 示例,请安装并初始化 gcloud CLI,然后使用您的用户凭证设置应用默认凭证。
如需了解详情,请参阅 Set up authentication for a local development environment。 如需了解详情,请参阅身份验证文档中的为本地开发环境设置 ADC。
REST
如需在本地开发环境中使用本页面上的 REST API 示例,请使用您提供给 gcloud CLI 的凭据。
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
如需了解详情,请参阅 Google Cloud 身份验证文档中的使用 REST 时进行身份验证。
所需的角色和权限
如需获得将 Hyperdisk 卷添加到实例所需的权限,请让您的管理员为您授予项目的以下 IAM 角色:
如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。
这些预定义角色可提供将 Hyperdisk 卷添加到实例所需的权限。如需查看所需的确切权限,请展开所需权限部分:
所需权限
如需将 Hyperdisk 磁盘卷添加到实例,您需要具备以下权限:
Hyperdisk 卷支持的值
大小限制
您为 Hyperdisk 卷指定的大小必须在下表中列出的范围内。
Hyperdisk 类型 大小下限 大小上限 默认大小 平衡 Hyperdisk 4 GiB 64 TiB 100 GiB Hyperdisk Balanced 高可用性 4 GiB 64 TiB 100 GiB Hyperdisk Extreme 64 GiB 64 TiB 1 TiB Hyperdisk ML 4 GiB 64 TiB 100 GiB Hyperdisk Throughput 2 TiB 32 TiB 2 TiB 不过,挂接到虚拟机的 Hyperdisk 卷的大小不能超过该虚拟机的 Hyperdisk 限制。
性能限制
下表列出了您可以为每种 Hyperdisk 类型指定的性能限制。不过,您可以指定的 IOPS 和吞吐量级别也取决于卷的大小。如需详细了解每项限制,请参阅 Hyperdisk Balanced、Hyperdisk Balanced 高可用性、Hyperdisk Extreme、Hyperdisk ML 和 Hyperdisk 吞吐量的大小和性能限制部分。
Hyperdisk 类型 IOPS 限制 吞吐量限制 (MiB/s) 平衡 Hyperdisk 160,000 2400 Hyperdisk Balanced 高可用性 100000 1,200 Hyperdisk Extreme 350,000 您无法为 Hyperdisk Extreme 卷预配吞吐量级别。每个卷每达到 1,000 IOPS 可获得 250 MiB/s 的吞吐量,最多为 5,000 MiB/s。 Hyperdisk ML 您无法预配 IOPS 级别,但每 MiB/s 预配吞吐量可带来 16 IOPS,最多可达 19,200,000 IOPS。 1,200,000 Hyperdisk Throughput 您无法预配 IOPS 级别,但每 MiB/s 的预配吞吐量可带来 4 IOPS,最多 2,400 IOPS。 600 Hyperdisk 类型变量
下表列出了每种 Hyperdisk 类型的参考值。使用 Google Cloud CLI、REST 或 Cloud Client Libraries for Compute Engine 创建 Hyperdisk 卷时,请通过提供表格中的相应值来指明要创建的 Hyperdisk 类型。
磁盘类型 参考名称 平衡 Hyperdisk hyperdisk-balanced
Hyperdisk Balanced 高可用性 hyperdisk-balanced-high-availability
Hyperdisk Extreme hyperdisk-extreme
Hyperdisk Throughput hyperdisk-throughput
Hyperdisk ML hyperdisk-ml
将 Hyperdisk 卷添加到实例
您可以使用Google Cloud 控制台、Google Cloud CLI 或 REST 创建并挂接 Hyperdisk 卷。
您在创建 Hyperdisk 卷时指定的大小、吞吐量和 IOPS 必须在支持的值范围内。
创建 Hyperdisk Balanced 卷时,您可以视情况通过采用多写入者模式创建磁盘来允许多个实例同时访问磁盘。
控制台
gcloud
REST
Go
Java
Node.js
创建磁盘后,您可以将磁盘挂接到任何正在运行或已停止的实例。
格式化并装载磁盘
创建新磁盘并将其挂接到实例后,必须格式化并装载磁盘,以便操作系统可以使用可用的存储空间。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-06-25。
-