Share via


使用命令列工具進行超大規模彈性集區作業

適用於:Azure SQL Database

在本文中,瞭解如何使用 Azure CLI 和 PowerShell 等命令行工具,建立、調整和行動資料庫到 超大規模資料庫彈性集 區。 除了這些方法之外,您隨時都可以針對大部分作業使用 Azure 入口網站。

注意

超大規模彈性集區目前為預覽版。

必要條件

若要使用超大規模資料庫彈性集區,您應該具備:

建立新的超大規模資料庫彈性集區

您可以使用 Azure CLI 或 Azure PowerShell 來建立超大規模資料庫彈性集區。

使用 az sql elastic-pool create 命令建立超大規模資料庫彈性集區。

下列範例會建立具有四個虛擬核心和兩個次要集區複本的超大規模彈性集區:

az sql elastic-pool create --resource-group "my-example-rg" --server "my-example-sql-svr" --name "my_hs_pool" --edition "Hyperscale" --capacity 4 --family Gen5 --ha-replicas 2

下列範例會建立具有四個虛擬核心和一個次要集區複本的區域備援超大規模資料庫彈性集區:

az sql elastic-pool create --resource-group "myresourcegroup" --server "mylogicalserver" --name "zr-hs-ep" --family Gen5 --edition Hyperscale --capacity 4 --ha-replicas 1 --zone-redundant

相應增加超大規模資料庫彈性集區

您可以使用 Azure CLI 或 Azure PowerShell 來相應增加現有的超大規模資料庫彈性集區。

使用 az sql elastic-pool update 命令來相應增加現有的超大規模資料庫彈性集區。

下列範例會將現有的超大規模資料庫彈性集區相應增加為8個虛擬核心,並將每個 DB 最小值和最大值分別設定為0和2:

az sql elastic-pool update --resource-group "my-example-rg" --server "my-example-sql-svr" --name "my_hs_pool" --capacity 8 --db-min-capacity 0 --db-max-capacity 2

相應放大(或縮小) 超大規模彈性集區

使用 Azure CLI 或 Azure PowerShell 來新增或移除現有超大規模資料庫彈性集區的次要集區複本,也稱為相應放大或相應縮小。

使用 az sql elastic-pool update 命令,藉由新增次要集區複本或在彈性集區中藉由移除次要集區複本來相應放大現有的超大規模彈性集區。

下列範例會相應放大現有的超大規模資料庫彈性集區,以使用四個次要集區複本:

# use the --ha-replicas (--read-replicas can also be used) parameter to specify the new number of high-availability replicas:
az sql elastic-pool update --resource-group "my-example-rg" --server "my-example-sql-svr" --name "my_hs_pool" --ha-replicas 4

下列範例會調整現有超大規模資料庫彈性集區,以使用一個次要集區複本:

# use the --ha-replicas (--read-replicas can also be used) parameter to specify the new number of high-availability replicas:
az sql elastic-pool update --resource-group "my-example-rg" --server "my-example-sql-svr" --name "my_hs_pool" --ha-replicas 1

將現有的資料庫移至超大規模資料庫彈性集區

您可以使用 Azure CLI 或 Azure PowerShell,將 Azure SQL 資料庫 中的現有資料庫移至現有的超大規模資料庫彈性集區。

使用 az sql db update 命令,將現有的資料庫移至現有的超大規模資料庫彈性集區。

下列範例會將資料庫 my_existing_db 移至現有的超大規模資料庫彈性集區 my_hs_pool

az sql db update --resource-group "my-example-rg" --server "my-example-sql-svr" --name "my_existing_db" --elastic-pool "my_hs_pool"

將現有的彈性集區從 Gen5 升級至進階系列硬體

您可以使用 Azure CLI 或 Azure PowerShell,將現有的彈性集區從 Gen5 升級為進階系列硬體。

目前無法透過 Azure CLI 使用。 請使用 PowerShell 或 Azure 入口網站。

將現有的一般用途資料庫移轉至區域備援超大規模資料庫彈性集區

您可以使用 Azure CLI 或 Azure PowerShell,將現有的一般用途資料庫移轉至區域備援超大規模資料庫彈性集區。

az sql db update --resource-group "myresourcegroup" --server "mylogicalserver" --name "gp_zrs_standalone_db" --elastic-pool "zr-hs-ep" --backup-storage-redundancy Zone

REST API

使用 2021-11-01 REST API(或更新版本)來處理超大規模資料庫彈性集區的次要複本。

下列範例會相應放大現有的超大規模資料庫彈性集區,以使用四個次要複本:

PATCH https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}?api-version=2021-11-01-preview

{
  "properties": {
    "highAvailabilityReplicaCount": 4
  }
}