Add-AzureRmSqlDatabaseToFailoverGroup
將一或多個資料庫新增至 Azure SQL 資料庫 故障轉移群組。
警告
自 2024 年 2 月 29 日起,AzureRM PowerShell 模組已正式淘汰。 建議使用者從 AzureRM 遷移至 Az PowerShell 模組,以確保持續支援和更新。
雖然 AzureRM 模組可能仍可運作,但不再維護或支援它,但會根據用戶的判斷權和風險放置任何繼續使用。 如需轉換至 Az 模組的指引,請參閱我們的 移轉資源 。
語法
Add-AzureRmSqlDatabaseToFailoverGroup
[-ServerName] <String>
[-FailoverGroupName] <String>
-Database <System.Collections.Generic.List`1[Microsoft.Azure.Commands.Sql.Database.Model.AzureSqlDatabaseModel]>
[-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
將 Azure SQL 資料庫 故障轉移群組主伺服器上的一或多個資料庫新增至該故障轉移群組。 資料庫不得為現有復寫關聯性的輔助資料庫。 此命令將會開始將任何新增的資料庫異地復寫至故障轉移群組的輔助伺服器。 若要取得要填入 '-Database' 參數的資料庫物件,請使用 Get-AzureRmSqlDatabase Cmdlet (例如) 。 故障轉移群組的主伺服器必須用來執行命令。
範例
範例 1
PS C:\> $failoverGroup = Get-AzureRmSqlDatabase -ResourceGroupName rg -ServerName primaryserver -DatabaseName db1 | Add-AzureRmSqlDatabaseToFailoverGroup -ResourceGroupName rg -ServerName primaryserver -FailoverGroupName fg
此命令會透過管線將一個資料庫新增至故障轉移群組。
範例 2
PS C:\> $primaryServer = Get-AzureRmSqlServer -ResourceGroupName rg -ServerName primaryserver
PS C:\> $failoverGroup = $primaryServer | Add-AzureRmSqlDatabaseToFailoverGroup -FailoverGroupName fg -Database ($primaryServer | Get-AzureRmSqlDatabase)
此命令會將伺服器中的所有資料庫新增至故障轉移群組。
範例 3
PS C:\> $failoverGroup = Get-AzureRmSqlDatabaseFailoverGroup -ResourceGroupName rg -ServerName primaryserver -FailoverGroupName fg
PS C:\> $databases = Get-AzureRmSqlElasticPoolDatabase -ResourceGroupName rg -ServerName primaryserver -ElasticPoolName pool1
PS C:\> $failoverGroup = $failoverGroup | Add-AzureRmSqlDatabaseToFailoverGroup -Database $databases
此命令會將彈性集區中的所有資料庫新增至故障轉移群組。
參數
-Database
故障轉移群組主伺服器上的一或多個 Azure SQL 資料庫,要新增至故障轉移群組。
類型: | List<T>[AzureSqlDatabaseModel] |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-DefaultProfile
用於與 azure 通訊的認證、帳戶、租用戶和訂用帳戶
類型: | IAzureContextContainer |
別名: | AzureRmContext, AzureCredential |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-FailoverGroupName
Azure SQL 資料庫 故障轉移群組的名稱。
類型: | String |
Position: | 2 |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-ResourceGroupName
資源群組的名稱。
類型: | String |
Position: | 0 |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-ServerName
故障轉移群組的主要 Azure SQL 資料庫 伺服器名稱。
類型: | String |
Position: | 1 |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
輸入
List<T>[[Microsoft.Azure.Commands.Sql.Database.Model.AzureSqlDatabaseModel, Microsoft.Azure.Commands.Sql, Version=4.11.0.0, Culture=neutral, PublicKeyToken=null]]