Share via


使用 Azure CLI 設定 適用於 PostgreSQL 的 Azure 資料庫 的智慧型手機調整 - 彈性伺服器

適用於:適用於 PostgreSQL 的 Azure 資料庫 - 彈性伺服器

您可以使用 Azure CLI 來驗證和更新 適用於 PostgreSQL 的 Azure 資料庫 彈性伺服器實例的智慧型微調組態。

若要深入瞭解智慧型手機調整,請參閱概

必要條件

  • 如果您沒有 Azure 訂用帳戶,請在開始前建立免費帳戶

  • 安裝或升級 Azure CLI 至最新版本。 請參閱 安裝 Azure CLI

  • 使用 az login 命令登入您的 Azure 帳戶。 請注意 屬性 id ,其會參考您 Azure 帳戶的訂用帳戶標識碼。

    az login
    
  • 如果您有多個訂用帳戶,請使用 命令選擇您想要在其中建立伺服器的適當訂用 az account set 帳戶:

    az account set --subscription <subscription id>
    
  • 如果您尚未建立 適用於 PostgreSQL 的 Azure 資料庫 彈性伺服器實例,請使用 az postgres flexible-server create 命令建立一個:

    az postgres flexible-server create --resource-group myresourcegroup --name myservername
    

確認目前的設定

使用 az postgres flexible-server 參數 show 命令來確認智慧型手機微調功能的目前設定。

您可以使用下列命令,確認是否已為資源群組myresourcegroup下的伺服器mydemoserver.postgres.database.azure.com啟用此功能:

az postgres flexible-server parameter show --resource-group myresourcegroup --server-name mydemoserver --name intelligent_tuning --query value

您可以使用下列命令來檢查伺服器參數的 intelligent_tuning.metric_targets 目前設定:

az postgres flexible-server parameter show --resource-group myresourcegroup --server-name mydemoserver --name intelligent_tuning.metric_targets --query value

啟用智慧型手機調整

若要啟用或停用智慧型手機微調,請使用 az postgres flexible-server 參數 set 命令。 您可以選擇下列微調目標:noneStorage-checkpoint_completion_target、、Storage-bgwriter_delayStorage-min_wal_sizeStorage-max_wal_sizetuning-autovacuumall

重要

目前針對具有四個或更多虛擬核心的一般用途和記憶體優化伺服器計算層,支援自動數據清理微調。 不支援高載伺服器計算層。

  1. 使用下列命令啟用智慧型手機微調功能:

    az postgres flexible-server parameter set --resource-group myresourcegroup --server-name mydemoserver --name intelligent_tuning --value ON
    
  2. 選取您想要啟動的微調目標。

    • 若要啟用所有微調目標,請使用下列命令:

      az postgres flexible-server parameter set --resource-group myresourcegroup --server-name mydemoserver --name intelligent_tuning.metric_targets --value all
      
    • 若要只啟用自動資料清理微調,請使用下列命令:

      az postgres flexible-server parameter set --resource-group myresourcegroup --server-name mydemoserver --name intelligent_tuning.metric_targets --value tuning-autovacuum
      
    • 若要啟用兩個微調目標,請使用下列命令:

      az postgres flexible-server parameter set --resource-group myresourcegroup --server-name mydemoserver --name intelligent_tuning.metric_targets --value tuning-autovacuum,Storage-bgwriter_delay
      

    如果您想要將參數的值重設為預設值,只要排除選擇性 --value 參數即可。 服務接著會套用預設值。 在上述範例中,命令看起來會像下面這樣,並將 設定 intelligent_tuning.metric_targetsnone

    az postgres flexible-server parameter set --resource-group myresourcegroup --server-name mydemoserver --name intelligent_tuning.metric_targets
    

注意

intelligent_tuningintelligent_tuning.metric_targets 伺服器參數都是動態的,這表示變更伺服器值時不需要重新啟動伺服器。

選取微調目標值的考慮

當您從 intelligent_tuning.metric_targets 伺服器參數選擇值時,請將下列考慮納入考慮:

  • 此值 NONE 優先於所有其他值。 如果您選擇 NONE 與其他值的任何組合,參數會被視為設定為 NONE。 這相當於 intelligent_tuning = OFF,因此不會發生任何微調。

  • ALL 優先於所有其他值,但 除外 NONE。 如果您選擇 ALL 任何組合,請禁止 NONE,所有列出的參數都會經過微調。

  • ALL 包含所有現有的計量目標。 這個值也會自動套用至未來可能會新增的任何新計量目標。 這可讓您對 適用於 PostgreSQL 的 Azure 資料庫 彈性伺服器實例進行全面且未來的微調。

  • 如果您想要包含另一個微調目標,您必須同時指定現有和新的微調目標。 例如,如果 bgwriter_delay 已啟用,而且您想要新增自動數據清理微調,則您的命令看起來應該像這樣:

    az postgres flexible-server parameter set --resource-group myresourcegroup --server-name mydemoserver --name intelligent_tuning.metric_targets --value tuning-autovacuum,Storage-bgwriter_delay
    

    只指定新的值會覆寫目前的設定。 當您新增微調目標時,請務必在命令中包含現有的微調目標。

下一步