简体   繁体   English

Azure SQL 通过 T-SQL 进行故障转移

[英]Azure SQL Failover through T-SQL

I am conducting some tests, therefore I have two instances each in a specific region, the database has been configured with a geo-replica and added to a failover group.我正在进行一些测试,因此我在一个特定区域中各有两个实例,数据库已配置一个异地副本并添加到故障转移组。

While trying to trigger a failover through SQL commands, it looks like it doesn't want to work, but when I am going and logging into the azure portal, and selecting the instance then to the failover group, I can trigger a failover and also a forced failover, both of them working just fine, I was wondering how would this work from a SQL perspective?在尝试通过 SQL 命令触发故障转移时,它似乎不想工作,但是当我要登录 azure 门户,然后选择实例到故障转移组时,我可以触发故障转移,并且强制故障转移,它们都工作得很好,我想知道从 SQL 的角度来看,这将如何工作?

To be noted the ALTER DATABASE [DB-NAME] FAILOVER;需要注意的是ALTER DATABASE [DB-NAME] FAILOVER; or ALTER AVAILABILITY GROUP [AGNAME] Failover;ALTER AVAILABILITY GROUP [AGNAME] Failover; doesn't work.不起作用。

Anyone experiencing similar issues?有人遇到类似问题吗?

Azure Failover doesn't support T-SQL approach. Azure 故障转移不支持 T-SQL 方法。

Auto-failover groups can be managed programmatically using Azure PowerShell, Azure CLI, and REST API. Auto-failover groups can be managed programmatically using Azure PowerShell, Azure CLI, and REST API.

To triggers failover of a failover group to the secondary server, use Switch-AzSqlDatabaseFailoverGroup Powershell command.要触发故障转移组到辅助服务器的故障转移,请使用Switch-AzSqlDatabaseFailoverGroup Powershell 命令。

The above command swaps the roles of the servers in a Failover Group and switches all secondary databases to the primary role.上述命令交换故障转移组中服务器的角色,并将所有辅助数据库切换为主角色。 All new TDS sessions are automatically re-routed to the secondary server after the DNS client cache is refreshed.刷新 DNS 客户端缓存后,所有新的 TDS 会话都会自动重新路由到辅助服务器。 When the original primary server is back online, all formerly primary databases in it will switch to the secondary role.当原始主服务器重新上线时,其中所有以前的主数据库都将切换到辅助角色。 The Failover Group's secondary server must be used to execute this command.必须使用故障转移组的辅助服务器来执行此命令。

Refer Switch-AzSqlDatabaseFailoverGroup to know more.请参阅Switch-AzSqlDatabaseFailoverGroup了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM