建立 Hyperdisk 集區

本文說明如何建立 Hyperdisk 集區。Hyperdisk 集區是區塊儲存空間資源,可協助您匯總管理 Hyperdisk 區塊儲存空間資源。Hyperdisk 集區有下列版本:

  • Hyperdisk 儲存空間集區:適合大多數工作負載
  • Hyperdisk Exapool:適合並行效能超過 100 GiB/s 的超大型工作負載

如要瞭解不同類型的 Hyperdisk 集區,請參閱「Hyperdisk 集區總覽」。

事前準備

  • 如果尚未設定驗證,請先完成設定。驗證機制會確認您的身分,以便授予 Google Cloud 服務和 API 的存取權。如要從本機開發環境執行程式碼或範例,您可以選取下列其中一個選項,向 Compute Engine 進行驗證:

    請根據您打算如何使用本頁範例,選取對應的分頁標籤:

    控制台

    使用 Google Cloud 控制台存取 Google Cloud 服務和 API 時,您不需要設定驗證機制。

    gcloud

    1. 安裝 Google Cloud CLI。 安裝完成後,請執行下列指令,初始化 Google Cloud CLI:

      gcloud init

      若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。

  • 設定預設區域和可用區。
  • Go

    如要在本機開發環境中使用本頁面的 Go 範例,請安裝並初始化 gcloud CLI,然後使用使用者憑證設定應用程式預設憑證。

    1. 安裝 Google Cloud CLI。

    2. 若您採用的是外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。

    3. 如果您使用的是本機殼層,請為使用者帳戶建立本機驗證憑證:

      gcloud auth application-default login

      如果您使用的是 Cloud Shell,則不必執行這項操作。

      如果系統傳回驗證錯誤,且您使用的是外部識別資訊提供者 (IdP),請確認您已使用聯合身分登入 gcloud CLI。

    詳情請參閱「為本機開發環境設定驗證機制」。

    Java

    如要在本機開發環境中使用本頁的 Java 範例,請安裝並初始化 gcloud CLI,然後使用使用者憑證設定應用程式預設憑證。

    1. 安裝 Google Cloud CLI。

    2. 若您採用的是外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。

    3. 如果您使用的是本機殼層,請為使用者帳戶建立本機驗證憑證:

      gcloud auth application-default login

      如果您使用的是 Cloud Shell,則不必執行這項操作。

      如果系統傳回驗證錯誤,且您使用的是外部識別資訊提供者 (IdP),請確認您已使用聯合身分登入 gcloud CLI。

    詳情請參閱「為本機開發環境設定驗證機制」。

    Node.js

    如要在本機開發環境中使用本頁的 Node.js 範例,請安裝並初始化 gcloud CLI,然後使用使用者憑證設定應用程式預設憑證。

    1. 安裝 Google Cloud CLI。

    2. 若您採用的是外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。

    3. 如果您使用的是本機殼層,請為使用者帳戶建立本機驗證憑證:

      gcloud auth application-default login

      如果您使用的是 Cloud Shell,則不必執行這項操作。

      如果系統傳回驗證錯誤,且您使用的是外部識別資訊提供者 (IdP),請確認您已使用聯合身分登入 gcloud CLI。

    詳情請參閱「為本機開發環境設定驗證機制」。

    REST

    如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。

      安裝 Google Cloud CLI。

      若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。

    詳情請參閱 Google Cloud 驗證說明文件中的「使用 REST 進行驗證」一節。

必要角色和權限

如要取得建立 Hyperdisk 集區所需的權限,請要求管理員授予您專案的下列 IAM 角色:

  • Compute 執行個體管理員 (v1) (roles/compute.instanceAdmin.v1)
  • 如要連線至可做為服務帳戶執行的 VM 執行個體:服務帳戶使用者 (v1) (roles/iam.serviceAccountUser 角色)

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

這些預先定義的角色具備建立 Hyperdisk 集區所需的權限。如要查看確切的必要權限,請展開「Required permissions」(必要權限) 部分:

所需權限

必須具備下列權限,才能建立 Hyperdisk 集區:

  • 專案的 compute.storagePools.create
  • 專案的 compute.storagePools.setLabels

您或許還可透過自訂角色或其他預先定義的角色取得這些權限。

限制

建立 Hyperdisk 儲存空間集區時,須遵守下列限制:

資源限制:

  • 建立 Hyperdisk 儲存空間集區時,佈建容量上限為 5 PiB。
  • 每小時最多可建立 5 個儲存空間集區。
  • 每天最多可建立 10 個儲存空間集區。
  • 每項專案在每個區域最多可建立 20 個儲存空間集區。這項限制由專案中位於相同區域的 Hyperdisk Balanced 儲存空間集區和 Hyperdisk Throughput 儲存空間集區共用。
  • 您無法變更集區的佈建模式。舉例來說,您無法將標準容量儲存空間集區變更為進階容量儲存空間集區,也無法將進階效能儲存空間集區變更為標準效能儲存空間集區。
  • 集區是可用區資源。
  • 一個儲存空間集區最多可建立 10,000 個磁碟。
  • Hyperdisk 儲存空間集區只能與 Compute Engine 搭配使用。Cloud SQL 執行個體無法使用 Hyperdisk 儲存空間集區。
  • 24 小時內,您最多可以變更儲存空間集區的佈建容量或效能兩次。
  • 您只能在 Hyperdisk Balanced 集區中建立 Hyperdisk Balanced 磁碟,以及在 Hyperdisk Throughput 集區中建立 Hyperdisk Throughput 磁碟。
  • 如要變更 Exapool 的佈建容量、IOPS 或處理量,請務必聯絡帳戶團隊。
  • 如要刪除 Exapool,請與帳戶團隊聯絡。

集區中的磁碟限制:

  • 只能在集區中建立相同專案和可用區的新磁碟。
  • 您無法將磁碟移入或移出集區,必須從標準快照重新建立磁碟。詳情請參閱「變更磁碟類型」。
  • 如要在集區中建立開機磁碟,必須使用 Hyperdisk Balanced 儲存空間集區或 Hyperdisk Balanced Exapool。
  • 集區不支援區域性磁碟。
  • 您無法複製集區中的磁碟、建立即時快照,或設定非同步複製。

容量範圍和佈建效能限制

建立儲存空間集區時,佈建的容量、IOPS 和處理量不得超過集區限制一節所述的上限。

建立 Hyperdisk 儲存空間集區

如要建立新的 Hyperdisk 儲存空間集區,請使用 Google Cloud 控制台、Google Cloud CLI 或 REST。建立儲存空間集區時,必須指定下列屬性:

  • 可用區
  • 儲存空間集區類型
  • 容量佈建模式
  • 已佈建的集區容量
  • 效能佈建類型
  • 已佈建集區的 IOPS 和處理量

控制台

  1. 前往 Google Cloud 控制台的「Create a storage pool」(建立儲存空間集區) 頁面。
    前往「Create Storage Pool」(建立儲存空間集區) 頁面
  2. 在「Name」(名稱) 欄位中,輸入儲存空間集區的專屬名稱。
  3. 選用:在「Description」(說明) 欄位中,輸入儲存空間集區的說明。
  4. 選取要建立儲存空間集區的「Region」(區域) 和「Zone」(可用區)。
  5. 選擇「Storage pool type」(儲存空間集區類型) 的值。
  6. 在「Capacity type」(容量類型) 欄位中選擇佈建類型,並在「Storage pool capacity」(儲存空間集區容量) 欄位中指定要為儲存空間集區佈建的容量。您可以指定 10 TiB 到 1 PiB 的大小。

    如要建立大容量儲存空間集區,您可能需要申請調整配額。

  7. 在「Performance type」(效能類型) 欄位中,選擇佈建類型。Hyperdisk 儲存空間集區可使用下列佈建類型:

    • 標準容量:在儲存空間集區中建立的每個磁碟,其佈建容量會從儲存空間集區的總佈建容量中扣除。
    • 進階容量:儲存空間集區可享有自動精簡配置和資料縮減功能。系統只會從儲存空間集區的已佈建總容量中,扣除實際寫入的資料量。
    • 標準效能:在儲存空間集區中建立的每個磁碟,其佈建效能會從儲存空間集區的總佈建效能中扣除。
    • 進階效能:為每個磁碟佈建的效能,都受惠於精簡佈建。只有磁碟使用的效能,才會從儲存空間集區的已佈建總效能中扣除。
  8. 如果是 Hyperdisk Balanced 儲存空間集區,請在「Provisioned IOPS」(佈建的 IOPS) 欄位中,輸入要為儲存空間集區佈建的 IOPS。

  9. 如果是 Hyperdisk Throughput 儲存空間集區或 Hyperdisk Balanced 儲存空間集區,請在「佈建輸送量」 欄位中,輸入要為儲存空間集區佈建的輸送量。

  10. 按一下「Submit」(提交),建立儲存空間集區。

gcloud

如要建立 Hyperdisk 儲存空間集區,請使用 gcloud compute storage-pools create 指令。

gcloud compute storage-pools create NAME  \
    --zone=ZONE   \
    --storage-pool-type=STORAGE_POOL_TYPE   \
    --capacity-provisioning-type=CAPACITY_TYPE \
    --provisioned-capacity=POOL_CAPACITY   \
    --performance-provisioning-type=PERFORMANCE_TYPE \
    --provisioned-iops=IOPS   \
    --provisioned-throughput=THROUGHPUT   \
    --description=DESCRIPTION

更改下列內容:

  • NAME:儲存空間集區的專屬名稱。
  • ZONE:要建立儲存空間集區的可用區,例如 us-central1-a。
  • STORAGE_POOL_TYPE:要儲存在儲存空間集區中的磁碟類型。允許的值為 hyperdisk-throughput 和 hyperdisk-balanced。
  • CAPACITY_TYPE:選用:儲存空間集區的容量佈建類型。允許的值為 advanced 和 standard。如未指定,則會使用 advanced 值。
  • POOL_CAPACITY:要為新儲存空間集區佈建的總容量,預設以 GiB 為單位。
  • PERFORMANCE_TYPE:選用:儲存空間集區的效能佈建類型。允許的值為 advanced 和 standard。如未指定,則會使用 advanced 值。
  • IOPS:要為儲存空間集區佈建的 IOPS。這個旗標只能與 Hyperdisk Balanced 儲存空間集區搭配使用。
  • THROUGHPUT:要為儲存空間集區佈建的處理量 (以 MB/秒為單位)。
  • DESCRIPTION:選用,說明儲存空間集區的文字字串。

REST

使用 storagePools.insert 方法建構 POST 要求,建立 Hyperdisk 儲存空間集區。

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/storagePools

{
    "name": "NAME",
    "description": "DESCRIPTION",
    "poolProvisionedCapacityGb": "POOL_CAPACITY",
    "storagePoolType": "projects/PROJECT_ID/zones/ZONE/storagePoolTypes/STORAGE_POOL_TYPE",
    "poolProvisionedIops": "IOPS",
    "poolProvisionedThroughput": "THROUGHPUT",
    "capacityProvisioningType": "CAPACITY_TYPE",
    "performanceProvisioningType": "PERFORMANCE_TYPE"
}

更改下列內容:

  • PROJECT_ID:專案 ID
  • ZONE:要建立儲存空間集區的可用區,例如 us-central1-a。
  • NAME:儲存空間集區的專屬名稱。
  • DESCRIPTION:選用,說明儲存空間集區的文字字串。
  • POOL_CAPACITY:要為新儲存空間集區佈建的總容量,預設以 GiB 為單位。
  • STORAGE_POOL_TYPE:要儲存在儲存空間集區中的磁碟類型。允許的值為 hyperdisk-throughput 和 hyperdisk-balanced。
  • IOPS:選用:要為儲存空間集區佈建的 IOPS。這個旗標只能與 Hyperdisk Balanced 儲存空間集區搭配使用。
  • THROUGHPUT:選用:要為儲存空間集區佈建的處理量 (以 MiB/s 為單位)。
  • CAPACITY_TYPE:選用:儲存空間集區的容量佈建類型。允許的值為 advanced 和 standard。如未指定,則會使用 advanced 值。
  • PERFORMANCE_TYPE:選用:儲存空間集區的效能佈建類型。允許的值為 advanced 和 standard。如未指定,則會使用 advanced 值。

Go


// createHyperdiskStoragePool creates a new Hyperdisk storage pool in the specified project and zone.
func createHyperdiskStoragePool(w io.Writer, projectId, zone, storagePoolName, storagePoolType string) error {
	// projectID := "your_project_id"
	// zone := "europe-west4-b"
	// storagePoolName := "your_storage_pool_name"
	// storagePoolType := "projects/**your_project_id**/zones/europe-west4-b/diskTypes/hyperdisk-balanced"

	ctx := context.Background()
	client, err := compute.NewStoragePoolsRESTClient(ctx)
	if err != nil {
		return fmt.Errorf("NewStoragePoolsRESTClient: %v", err)
	}
	defer client.Close()

	// Create the storage pool resource
	resource := &computepb.StoragePool{
		Name:                        proto.String(storagePoolName),
		Zone:                        proto.String(zone),
		StoragePoolType:             proto.String(storagePoolType),
		CapacityProvisioningType:    proto.String("advanced"),
		PerformanceProvisioningType: proto.String("advanced"),
		PoolProvisionedCapacityGb:   proto.Int64(10240),
		PoolProvisionedIops:         proto.Int64(10000),
		PoolProvisionedThroughput:   proto.Int64(1024),
	}

	// Create the insert storage pool request
	req := &computepb.InsertStoragePoolRequest{
		Project:             projectId,
		Zone:                zone,
		StoragePoolResource: resource,
	}

	// Send the insert storage pool request
	op, err := client.Insert(ctx, req)
	if err != nil {
		return fmt.Errorf("Insert storage pool request failed: %v", err)
	}

	// Wait for the insert storage pool operation to complete
	if err = op.Wait(ctx); err != nil {
		return fmt.Errorf("unable to wait for the operation: %w", err)
	}

	// Retrieve and return the created storage pool
	storagePool, err := client.Get(ctx, &computepb.GetStoragePoolRequest{
		Project:     projectId,
		Zone:        zone,
		StoragePool: storagePoolName,
	})
	if err != nil {
		return fmt.Errorf("Get storage pool request failed: %v", err)
	}

	fmt.Fprintf(w, "Hyperdisk Storage Pool created: %v\n", storagePool.GetName())
	return nil
}

Java

import com.google.cloud.compute.v1.InsertStoragePoolRequest;
import com.google.cloud.compute.v1.Operation;
import com.google.cloud.compute.v1.StoragePool;
import com.google.cloud.compute.v1.StoragePoolsClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CreateHyperdiskStoragePool {
  public static void main(String[] args)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    // Project ID or project number of the Google Cloud project you want to use.
    String projectId = "YOUR_PROJECT_ID";
    // Name of the zone in which you want to create the storagePool.
    String zone = "us-central1-a";
    // Name of the storagePool you want to create.
    String storagePoolName = "YOUR_STORAGE_POOL_NAME";
    // The type of disk you want to create.
    // Storage types can be "hyperdisk-throughput" or "hyperdisk-balanced"
    String storagePoolType = String.format(
        "projects/%s/zones/%s/storagePoolTypes/hyperdisk-balanced", projectId, zone);
    // Optional: the capacity provisioning type of the storage pool.
    // The allowed values are advanced and standard. If not specified, the value advanced is used.
    String capacityProvisioningType = "advanced";
    // The total capacity to provision for the new storage pool, specified in GiB by default.
    long provisionedCapacity = 128;
    // the IOPS to provision for the storage pool.
    // You can use this flag only with Hyperdisk Balanced Storage Pools.
    long provisionedIops = 3000;
    // the throughput in MBps to provision for the storage pool.
    long provisionedThroughput = 140;
    // The allowed values are low-casing strings "advanced" and "standard".
    // If not specified, "advanced" is used.
    String performanceProvisioningType = "advanced";

    createHyperdiskStoragePool(projectId, zone, storagePoolName, storagePoolType,
            capacityProvisioningType, provisionedCapacity, provisionedIops,
        provisionedThroughput, performanceProvisioningType);
  }

  // Creates a hyperdisk storagePool in a project
  public static StoragePool createHyperdiskStoragePool(String projectId, String zone,
        String storagePoolName, String storagePoolType, String capacityProvisioningType,
        long capacity, long iops, long throughput, String performanceProvisioningType)
          throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (StoragePoolsClient client = StoragePoolsClient.create()) {
      // Create a storagePool.
      StoragePool resource = StoragePool.newBuilder()
              .setZone(zone)
              .setName(storagePoolName)
              .setStoragePoolType(storagePoolType)
              .setCapacityProvisioningType(capacityProvisioningType)
              .setPoolProvisionedCapacityGb(capacity)
              .setPoolProvisionedIops(iops)
              .setPoolProvisionedThroughput(throughput)
              .setPerformanceProvisioningType(performanceProvisioningType)
              .build();

      InsertStoragePoolRequest request = InsertStoragePoolRequest.newBuilder()
              .setProject(projectId)
              .setZone(zone)
              .setStoragePoolResource(resource)
              .build();

      // Wait for the insert disk operation to complete.
      Operation operation = client.insertAsync(request).get(1, TimeUnit.MINUTES);

      if (operation.hasError()) {
        System.out.println("StoragePool creation failed!");
        throw new Error(operation.getError().toString());
      }

      // Wait for server update
      TimeUnit.SECONDS.sleep(10);

      StoragePool storagePool = client.get(projectId, zone, storagePoolName);

      System.out.printf("Storage pool '%s' has been created successfully", storagePool.getName());

      return storagePool;
    }
  }
}

Node.js

// Import the Compute library
const computeLib = require('@google-cloud/compute');
const compute = computeLib.protos.google.cloud.compute.v1;

// Instantiate a storagePoolClient
const storagePoolClient = new computeLib.StoragePoolsClient();
// Instantiate a zoneOperationsClient
const zoneOperationsClient = new computeLib.ZoneOperationsClient();

/**
 * TODO(developer): Update/uncomment these variables before running the sample.
 */
// Project ID or project number of the Google Cloud project you want to use.
const projectId = await storagePoolClient.getProjectId();
// Name of the zone in which you want to create the storagePool.
const zone = 'us-central1-a';
// Name of the storagePool you want to create.
// storagePoolName = 'storage-pool-name';
// The type of disk you want to create. This value uses the following format:
// "projects/{projectId}/zones/{zone}/storagePoolTypes/(hyperdisk-throughput|hyperdisk-balanced)"
const storagePoolType = `projects/${projectId}/zones/${zone}/storagePoolTypes/hyperdisk-balanced`;
// Optional: The capacity provisioning type of the storage pool.
// The allowed values are advanced and standard. If not specified, the value advanced is used.
const capacityProvisioningType = 'advanced';
// The total capacity to provision for the new storage pool, specified in GiB by default.
const provisionedCapacity = 10240;
// The IOPS to provision for the storage pool.
// You can use this flag only with Hyperdisk Balanced Storage Pools.
const provisionedIops = 10000;
// The throughput in MBps to provision for the storage pool.
const provisionedThroughput = 1024;
// Optional: The performance provisioning type of the storage pool.
// The allowed values are advanced and standard. If not specified, the value advanced is used.
const performanceProvisioningType = 'advanced';

async function callCreateComputeHyperdiskPool() {
  // Create a storagePool.
  const storagePool = new compute.StoragePool({
    name: storagePoolName,
    poolProvisionedCapacityGb: provisionedCapacity,
    poolProvisionedIops: provisionedIops,
    poolProvisionedThroughput: provisionedThroughput,
    storagePoolType,
    performanceProvisioningType,
    capacityProvisioningType,
    zone,
  });

  const [response] = await storagePoolClient.insert({
    project: projectId,
    storagePoolResource: storagePool,
    zone,
  });

  let operation = response.latestResponse;

  // Wait for the create storage pool operation to complete.
  while (operation.status !== 'DONE') {
    [operation] = await zoneOperationsClient.wait({
      operation: operation.name,
      project: projectId,
      zone: operation.zone.split('/').pop(),
    });
  }

  console.log(`Storage pool: ${storagePoolName} created.`);
}

await callCreateComputeHyperdiskPool();

建立 Hyperdisk Exapool

Hyperdisk Exapool 已正式發布,但須加入許可清單。如要建立 Hyperdisk Exapool,請與帳戶團隊聯絡。

後續步驟