[英]Autoscaling Azure SQL Database
我們有一個使用Azure SQL作為數據庫后端的應用程序。 在正常負載/條件下,此數據庫可以在Premium 1計划上成功運行。 但是,在凌晨時分,我們有一些工作會增加數據庫負載。 在這幾個小時內,我們需要轉向Premium 3計划。 Premium 3的成本大約是8倍,所以顯然我們不想支付全天候運行此計划的成本。
是否可以上下自動調整數據庫? 雲服務提供了一種簡單的方法來擴展Azure門戶中的實例數量,但是,Azure SQL數據庫不存在這樣的情況。 可以使用Azure SDK以編程方式完成嗎? 我無法找到有關此主題的任何文檔。
在深入了解@ ErikEJ的答案(謝謝!)之后,我能夠找到以下內容,這些內容似乎是隨着Elastic Scale預覽的發布而新發布的:
現在還提供了以下REST API,它們可以讓您在數據庫中執行任何操作:
對於我縮放服務層的原始問題(例如P1 - > P3 - > P1):
通過這些新的開發,我將假設自動縮放也可以作為Azure門戶中的簡單配置提供,這與雲服務非常相似。
是的,該功能可用:Azure SQL數據庫彈性比例
https://docs.microsoft.com/en-gb/azure/sql-database/sql-database-elastic-scale-introduction
另一種方法是使用Azure自動化並使用下面的運行手冊:
param
(
# Desired Azure SQL Database edition {Basic, Standard, Premium}
[parameter(Mandatory=$true)]
[string] $Edition,
# Desired performance level {Basic, S0, S1, S2, P1, P2, P3}
[parameter(Mandatory=$true)]
[string] $PerfLevel
)
inlinescript
{
# I only care about 1 DB so, I put it into variable asset and access from here
$SqlServerName = Get-AutomationVariable -Name 'SqlServerName'
$DatabaseName = Get-AutomationVariable -Name 'DatabaseName'
Write-Output "Begin vertical scaling script..."
# Establish credentials for Azure SQL Database server
$Servercredential = new-object System.Management.Automation.PSCredential("yourDBadmin", ("YourPassword" | ConvertTo-SecureString -asPlainText -Force))
# Create connection context for Azure SQL Database server
$CTX = New-AzureSqlDatabaseServerContext -ManageUrl “https://$SqlServerName.database.windows.net” -Credential $ServerCredential
# Get Azure SQL Database context
$Db = Get-AzureSqlDatabase $CTX –DatabaseName $DatabaseName
# Specify the specific performance level for the target $DatabaseName
$ServiceObjective = Get-AzureSqlDatabaseServiceObjective $CTX -ServiceObjectiveName "$Using:PerfLevel"
# Set the new edition/performance level
Set-AzureSqlDatabase $CTX –Database $Db –ServiceObjective $ServiceObjective –Edition $Using:Edition -Force
# Output final status message
Write-Output "Scaled the performance level of $DatabaseName to $Using:Edition - $Using:PerfLevel"
Write-Output "Completed vertical scale"
}
參考:
Azure垂直擴展Runbook
當您想要放大/縮小時設置時間表。
對我來說,我使用2個帶有輸入參數的時間表,1個用於放大,另一個用於縮小。
希望有所幫助。
在某些情況下,最簡單的選擇可能是運行SQL查詢, 如msdn中所述 。
例如:
ALTER DATABASE [database_name] MODIFY (EDITION = 'standard', SERVICE_OBJECTIVE = 'S3', MAXSIZE = 250 GB)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.