如要將 Hyperdisk Balanced、Hyperdisk Extreme 或 Hyperdisk Throughput 磁碟區與 Compute Engine 執行個體搭配使用,請完成下列工作:
- 建立空白的非開機可用區 Hyperdisk 磁碟區,並在建立執行個體時或之後將其附加至執行個體。
- 格式化並掛接磁碟區,以存取資料或檔案系統。
對於 Hyperdisk Balanced 磁碟區,您也可以建立開機磁碟和資料磁碟。
如要瞭解 Hyperdisk 的一般資訊,請參閱「關於 Hyperdisk」。
如要將 Hyperdisk Balanced High Availability 磁碟新增至執行個體,請按照下列程序操作:
事前準備
- 將 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 Balanced 磁碟區,您可以建立處於多重寫入模式的磁碟,啟用將磁碟連接至多個執行個體的功能。在「存取模式」下方,選取「以讀寫模式連接多個 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 磁碟,這是指磁碟每秒可處理的 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 High Availability),可供多個執行個體同時讀寫存取。- (僅限 Hyperdisk ML) 可供多個執行個體同時進行唯讀存取。
READ_ONLY_MANY
如要設定 Hyperdisk Balanced High Availability 磁碟的存取模式,請參閱建立區域磁碟。
選用:使用
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 Balanced High Availability 磁碟的存取模式,請參閱建立區域磁碟。
選用:使用
compute.disks.get
方法查看磁碟說明。建立磁碟後,您可以將磁碟連接至任何執行中或已停止的執行個體。
- Linux:請參閱「在 Linux Compute 執行個體上格式化及掛接非開機磁碟」
- Windows:請參閱「在 Windows Compute 執行個體上格式化及掛接非開機磁碟」
- 瞭解如何自訂 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 驗證說明文件中的「Authenticate for using 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 級別,但每佈建 1 MiB/s 的輸送量,就會有 16 個 IOPS,最多可達 19,200,000 個 IOPS。 1,200,000 Hyperdisk Throughput 您無法佈建 IOPS 級別,但每佈建 1 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 Balanced 磁碟區時,您可以選擇以多重寫入模式建立磁碟,允許多個執行個體同時存取磁碟。
主控台
gcloud
REST
Go
Java
Node.js
建立磁碟後,您可以將磁碟連接至任何執行中或已停止的執行個體。
格式化並掛接磁碟
建立新磁碟並將該磁碟連接至執行個體之後,必須格式化和掛接磁碟,好讓作業系統能使用可用的儲存空間。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-09 (世界標準時間)。
-