您可以完成下列工作,在 Compute Engine 執行個體中使用 Hyperdisk Balanced、Hyperdisk Extreme 或 Hyperdisk Throughput 磁碟分割區:
- 建立空白、非開機和可用區 Hyperdisk 磁碟區,並在建立執行個體時或之後將其附加至執行個體。
- 格式化及掛接磁碟區,以便存取資料或檔案系統。
對於 Hyperdisk Balanced 磁碟區,您也可以建立啟動磁碟和資料磁碟。
如需 Hyperdisk 的一般資訊,請參閱「關於 Hyperdisk」一文。
如要為執行個體新增 Hyperdisk 平衡高可用性磁碟,請按照下列程序操作:
事前準備
- 在將 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 執行個體管理員 (v1) (
roles/compute.instanceAdmin.v1
) -
如要連線至可以以服務帳戶身分執行的執行個體,請按照下列步驟操作:
服務帳戶使用者 (v1) (
roles/iam.serviceAccountUser
) -
如要建立及附加 Hyperdisk 磁碟區,請按照下列步驟操作:
-
compute.disks.create
專案 -
執行個體的
compute.instances.attachDisk
權限 -
compute.disks.use
在要連結至執行個體的磁碟上
-
-
如要格式化及掛接已連結的磁碟區,請按照下列步驟操作:
compute.instances.setMetadata
在執行個體上 前往「VM instances」(VM 執行個體) 頁面。
按一下您要為其新增磁碟的執行個體名稱。
在「VM instance details」(VM 執行個體詳細資料) 頁面上,按一下 [Edit] (編輯)。
在「Additional disks」(其他磁碟) 標題下方,點選「Add new disk」(增加新磁碟)。
指定磁碟名稱,並視需要加入說明。選取「磁碟來源類型」的「空白磁碟」。
在「磁碟設定」下方,從下列清單中選擇磁碟類型。您指定的值必須在支援的值範圍內。
- Hyperdisk Balanced。您也可以變更預設磁碟的大小、已配置的 IOPS 和已配置的傳輸量設定。
- Hyperdisk Extreme。您也可以變更預設磁碟的大小和已配置 IOPS 設定。
- Hyperdisk ML。您也可以變更預設磁碟大小和已配置的傳輸量設定。
- Hyperdisk 處理量。您也可以變更預設磁碟的大小和已佈建的處理量設定。
選用:針對 Hyperdisk 平衡磁區,您可以透過在多重寫入模式下建立磁碟,啟用將磁碟連接至多個執行個體的功能。在「存取模式」下方,選取「以讀寫模式連接多個 VM」。
按一下 [儲存]。
如要將變更套用至執行個體,請按一下「儲存」。
使用
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 處理量:從 2 TiB 到 32 TiB (含),以 1 GiB 為單位遞增。
DISK_TYPE
:磁碟類型。請使用下列其中一個值:hyperdisk-balanced
、hyperdisk-extreme
、hyperdisk-ml
或hyperdisk-throughput
IOPS_LIMIT
:選用:對於 Hyperdisk Balanced 或 Hyperdisk Extreme 磁碟,這是磁碟可處理的每秒輸入/輸出作業數 (IOPS)。THROUGHPUT_LIMIT
:選用:對於 Hyperdisk Balanced、Hyperdisk ML 或 Hyperdisk Throughput 磁碟區,此為整數,代表磁碟可提供的最大處理量,以每秒 MiB 為單位。DISK_ACCESS_MODE
:選用:計算機例如何存取磁碟上的資料。支援的值如下:READ_WRITE_SINGLE
,用於從單一執行個體讀取/寫入資料。這是目前的預設做法。READ_WRITE_MANY
(僅限 Hyperdisk Balanced 和 Hyperdisk Balanced High Availability),用於從多個執行個體同時讀寫存取。READ_ONLY_MANY
(僅限 Hyperdisk ML),適用於從多個執行個體同時存取唯讀資料。
如要設定 Hyperdisk 平衡高可用性磁碟的存取模式,請參閱「建立區域磁碟」。
選用:使用
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 High Availability),用於從多個執行個體同時讀寫存取。READ_ONLY_MANY
(僅限 Hyperdisk ML),適用於從多個執行個體同時存取唯讀資料。
如要設定 Hyperdisk 平衡高可用性磁碟的存取模式,請參閱「建立區域磁碟」。
選用:使用
compute.disks.get
方法查看磁碟說明。建立磁碟後,您可以將磁碟連接至任何執行中或已停止的執行個體。
- Linux:請參閱「在 Linux 運算執行個體上格式化及掛接非啟動磁碟」一文
- Windows:請參閱「在 Windows 運算執行個體上格式化及掛接非啟動磁碟」
- 瞭解如何自訂 Hyperdisk 磁碟區的 IOPS 和傳輸量。
- 瞭解如何定期使用快照備份磁碟,以免不慎遺失資料。
Go
如要在本機開發環境中使用本頁面上的 Go 範例,請先安裝並初始化 gcloud CLI,然後使用您的使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
Java
如要在本機開發環境中使用本頁面上的 Java 範例,請先安裝並初始化 gcloud CLI,然後使用您的使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
Node.js
如要在本機開發環境中使用本頁面上的 Node.js 範例,請先安裝並初始化 gcloud CLI,然後使用您的使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
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 Balanced 4 GiB 64 TiB 100 GiB Hyperdisk Balanced High Availability 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 不過,連接至 VM 的 Hyperdisk 磁碟區大小不得超過 VM 的 Hyperdisk 限制。
效能限制
下表列出可為每種 Hyperdisk 類型指定的效能限制。不過,您可以指定的 IOPS 和處理量層級也取決於磁碟區的大小。如需各項限制的詳細摘要,請參閱 Hyperdisk Balanced、Hyperdisk Balanced High Availability、Hyperdisk Extreme、Hyperdisk ML 和 Hyperdisk Throughput 的「大小和效能限制」一節。
Hyperdisk 類型 IOPS 限制 處理量上限 (MiB/秒) Hyperdisk Balanced 160,000 2,400 Hyperdisk Balanced High Availability 100,000 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 或 Compute Engine 的 Cloud 用戶端程式庫建立 Hyperdisk 磁碟區時,請提供表格中的對應值,指出要建立的 Hyperdisk 類型。
磁碟類型 參照名稱 Hyperdisk Balanced hyperdisk-balanced
Hyperdisk Balanced High Availability 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 平衡磁碟區時,您可以選擇在多重寫入模式下建立磁碟,讓多個執行個體同時存取磁碟。
主控台
gcloud
REST
Go
Java
Node.js
建立磁碟後,您可以將磁碟連接至任何執行中或已停止的執行個體。
格式化及掛接磁碟
建立並將新磁碟連接至執行個體後,必須格式化和掛接磁碟,好讓作業系統能使用可用的儲存空間。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-06-16 (世界標準時間)。
-