Skip to content

Commit 4e98b7d

Browse files
authored
Merge pull request #3992 from paulathurman/perform-a-planned-manual-failover-of-an-availability-group-sql-server
Edit pass: Perform a planned manual failover of an availability group sql server
2 parents 2fbf4b7 + 3514ab2 commit 4e98b7d

6 files changed

Lines changed: 152 additions & 174 deletions
Lines changed: 56 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Perform a Planned Manual Failover of an Availability Group (SQL Server) | Microsoft Docs"
2+
title: "Perform a planned manual failover of an availability group (SQL Server) | Microsoft Docs"
33
ms.custom: ""
44
ms.date: "10/25/2017"
55
ms.prod: "sql-non-specified"
@@ -24,125 +24,105 @@ ms.author: "mikeray"
2424
manager: "jhubbard"
2525
ms.workload: "On Demand"
2626
---
27-
# Perform a Planned Manual Failover of an Availability Group (SQL Server)
27+
28+
# Perform a planned manual failover of an availability group (SQL Server)
2829
[!INCLUDE[appliesto-ss-xxxx-xxxx-xxx-md](../../../includes/appliesto-ss-xxxx-xxxx-xxx-md.md)]
29-
This topic describes how to perform a manual failover without data loss (a *planned manual failover*) on an Always On availability group by using [!INCLUDE[ssManStudioFull](../../../includes/ssmanstudiofull-md.md)], [!INCLUDE[tsql](../../../includes/tsql-md.md)], or PowerShell in [!INCLUDE[ssCurrent](../../../includes/sscurrent-md.md)]. An availability group fails over at the level of an availability replica. A planned manual failover, like any [!INCLUDE[ssHADR](../../../includes/sshadr-md.md)] failover, transitions a secondary replica to primary role and, concurrently, transitions the former primary replica to the secondary role.
30+
This topic describes how to perform a manual failover without data loss (a *planned manual failover*) on an AlwaysOn availability group by using [!INCLUDE[ssManStudioFull](../../../includes/ssmanstudiofull-md.md)], [!INCLUDE[tsql](../../../includes/tsql-md.md)], or PowerShell in [!INCLUDE[ssCurrent](../../../includes/sscurrent-md.md)]. An availability group fails over at the level of an availability replica. A planned manual failover, like any AlwaysOn availability group failover, transitions a secondary replica to primary role. Concurrently, the failover transitions the former primary replica to the secondary role.
3031

31-
A planned manual failover, which is supported only when the primary replica and the target secondary replica are running in synchronous-commit mode and are currently synchronized, preserves all the data in the secondary databases that are joined to the availability group on the target secondary replica. Once the former primary replica transitions to the secondary role, its databases become secondary databases and begin synchronizing with the new primary databases. After they all transition into the SYNCHRONIZED state, the new secondary replica becomes eligible to serve as the target of a future planned manual failover.
32+
A planned manual failover is supported only when the primary replica and the target secondary replica are running in synchronous-commit mode and are currently synchronized. A planned manual failver preserves all the data in the secondary databases that are joined to the availability group on the target secondary replica. After the former primary replica transitions to the secondary role, its databases become secondary databases. Then they begin to synchronize with the new primary databases. After they all transition into the SYNCHRONIZED state, the new secondary replica becomes eligible to serve as the target of a future planned manual failover.
3233

3334
> [!NOTE]
34-
> If the secondary and primary replicas are both configured for automatic failover mode, once the secondary replica is synchronized, it can also serve as the target for an automatic failover. For more information, see [Availability Modes (Always On Availability Groups)](../../../database-engine/availability-groups/windows/availability-modes-always-on-availability-groups.md).
35-
36-
- **Before you begin:**
37-
38-
[Limitations and Restrictions](#Restrictions)
39-
40-
[Prerequisites and Restrictions](#Prerequisites)
41-
42-
[Security](#Security)
43-
44-
- **To manually fail over an availability group, using:**
45-
46-
[SQL Server Management Studio](#SSMSProcedure)
47-
48-
[Transact-SQL](#TsqlProcedure)
49-
50-
[PowerShell](#PowerShellProcedure)
51-
52-
- **Follow Up:** [After Manually Failing Over an Availability Group](#FollowUp)
53-
54-
## <a name="BeforeYouBegin"></a> Before You Begin
35+
> If the secondary and primary replicas are both configured for automatic failover mode, after the secondary replica is synchronized, it also can serve as the target for an automatic failover. For more information, see [Availability modes &#40;AlwaysOn availability groups&#41;](../../../database-engine/availability-groups/windows/availability-modes-always-on-availability-groups.md).
36+
37+
## <a name="BeforeYouBegin"></a> Before you begin
5538

5639
>[!IMPORTANT]
57-
>There are specific procedures to failover a read-scale availability group with no cluster manager. When an availability group has CLUSTER_TYPE = NONE, follow the procedures under [Fail over primary replica on read-scale availability group](#ReadScaleOutOnly).
40+
>There are specific procedures to fail over a read-scale availability group with no cluster manager. When an availability group has CLUSTER_TYPE = NONE, follow the procedures under [Fail over the primary replica on a read-scale availability group](#Fail-over-the-primary-replica-on-a-read-scale-availability-group).
5841
59-
### <a name="Restrictions"></a> Limitations and Restrictions
60-
61-
- A failover command returns as soon as the target secondary replica has accepted the command. However, database recovery occurs asynchronously after the availability group has finished failing over.
62-
63-
- Cross-database consistency across databases within the availability group might not be maintained on failover.
64-
65-
> [!NOTE]
66-
> Support for cross-database and distributed transactions vary by SQL Server and operating system versions. For more information, see [Cross-Database Transactions and Distributed Transactions for Always On Availability Groups and Database Mirroring &#40;SQL Server&#41;](../../../database-engine/availability-groups/windows/transactions-always-on-availability-and-database-mirroring.md).
42+
### <a name="Restrictions"></a> Limitations and restrictions
6743

68-
### <a name="Prerequisites"></a> Prerequisites and Restrictions
44+
- A failover command returns as soon as the target secondary replica has accepted the command. However, database recovery occurs asynchronously after the availability group has finished failing over.
45+
- Cross-database consistency across databases within the availability group might not be maintained on failover.
6946

70-
- The target secondary replica and the primary replica must both be running in synchronous-commit availability mode.
47+
> [!NOTE]
48+
> Support for cross-database and distributed transactions vary by SQL Server and operating system versions. For more information, see [Cross-database transactions and distributed transactions for AlwaysOn availability groups and database mirroring &#40;SQL Server&#41;](../../../database-engine/availability-groups/windows/transactions-always-on-availability-and-database-mirroring.md).
7149
72-
- The target secondary replica must currently be synchronized with the primary replica. This requires that all the secondary databases on this secondary replica must have been joined to the availability group and be synchronized with their corresponding primary databases (that is, the local secondary databases must be SYNCHRONIZED).
50+
### <a name="Prerequisites"></a> Prerequisites and restrictions
7351

74-
> [!TIP]
75-
> To determine the failover readiness of an secondary replica, query the **is_failover_ready** column in the [sys.dm_hadr_database_cluster_states](../../../relational-databases/system-dynamic-management-views/sys-dm-hadr-database-replica-cluster-states-transact-sql.md) dynamic management view, or look at the **Failover Readiness** column of the [Always On Group Dashboard](../../../database-engine/availability-groups/windows/use-the-always-on-dashboard-sql-server-management-studio.md).
52+
- Both the target secondary replica and the primary replica must be running in synchronous-commit availability mode.
53+
- Currently, the target secondary replica must be synchronized with the primary replica. All the secondary databases on this secondary replica must be joined to the availability group. They also must be synchronized with their corresponding primary databases (that is, the local secondary databases must be SYNCHRONIZED).
7654

77-
- This task is supported only on the target secondary replica. You must be connected to the server instance that hosts the target secondary replica.
55+
> [!TIP]
56+
> To determine the failover readiness of a secondary replica, query the **is_failover_ready** column in the [sys.dm_hadr_database_cluster_states](../../../relational-databases/system-dynamic-management-views/sys-dm-hadr-database-replica-cluster-states-transact-sql.md) dynamic management view. Or you can look at the **Failover Readiness** column of the [AlwaysOn group dashboard](../../../database-engine/availability-groups/windows/use-the-always-on-dashboard-sql-server-management-studio.md).
57+
- This task is supported only on the target secondary replica. You must be connected to the server instance that hosts the target secondary replica.
7858

79-
### <a name="Security"></a> Security
59+
### <a name="Security"></a> Security
8060

81-
#### <a name="Permissions"></a> Permissions
82-
Requires ALTER AVAILABILITY GROUP permission on the availability group, CONTROL AVAILABILITY GROUP permission, ALTER ANY AVAILABILITY GROUP permission, or CONTROL SERVER permission.
61+
#### <a name="Permissions"></a> Permissions
62+
The ALTER AVAILABILITY GROUP permission is required on the availability group. The CONTROL AVAILABILITY GROUP permission, the ALTER ANY AVAILABILITY GROUP permission, or the CONTROL SERVER permission also is required.
8363

84-
## <a name="SSMSProcedure"></a> Using SQL Server Management Studio
85-
**To manually fail over an availability group**
64+
## <a name="SSMSProcedure"></a> Use SQL Server Management Studio
65+
To manually fail over an availability group:
8666

87-
1. In Object Explorer, connect to a server instance that hosts a secondary replica of the availability group that needs to be failed over, and expand the server tree.
67+
1. In Object Explorer, connect to a server instance that hosts a secondary replica of the availability group that needs to be failed over. Expand the server tree.
8868

89-
2. Expand the **Always On High Availability** node and the **Availability Groups** node.
69+
2. Expand the **AlwaysOn High Availability** node and the **Availability Groups** node.
9070

91-
3. Right-click the availability group to be failed over, and select the **Failover** command.
71+
3. Right-click the availability group to be failed over, and select **Failover**.
9272

93-
4. This launches the Failover Availability Group Wizard. For more information, see [Use the Fail Over Availability Group Wizard &#40;SQL Server Management Studio&#41;](../../../database-engine/availability-groups/windows/use-the-fail-over-availability-group-wizard-sql-server-management-studio.md).
73+
4. The Failover Availability Group wizard starts. For more information, see [Use the Failover Availability Group wizard &#40;SQL Server Management Studio&#41;](../../../database-engine/availability-groups/windows/use-the-fail-over-availability-group-wizard-sql-server-management-studio.md).
9474

95-
## <a name="TsqlProcedure"></a> Using Transact-SQL
96-
**To manually fail over an availability group**
75+
## <a name="TsqlProcedure"></a> Use Transact-SQL
76+
To manually fail over an availability group:
9777

98-
1. Connect to the server instance that hosts the target secondary replica.
78+
1. Connect to the server instance that hosts the target secondary replica.
9979

100-
2. Use the [ALTER AVAILABILITY GROUP](../../../t-sql/statements/alter-availability-group-transact-sql.md) statement, as follows:
80+
2. Use the [ALTER AVAILABILITY GROUP](../../../t-sql/statements/alter-availability-group-transact-sql.md) statement, as follows:
10181

102-
ALTER AVAILABILITY GROUP *group_name* FAILOVER
82+
ALTER AVAILABILITY GROUP *group_name* FAILOVER
10383

104-
where *group_name* is the name of the availability group.
84+
In the statement, *group_name* is the name of the availability group.
10585

106-
The following example manually fails over the *MyAg* availability group to the connected secondary replica.
86+
The following example manually fails over the *MyAg* availability group to the connected secondary replica:
10787

10888
```
10989
ALTER AVAILABILITY GROUP MyAg FAILOVER;
11090
```
11191
112-
## <a name="PowerShellProcedure"></a> Using PowerShell
113-
**To manually fail over an availability group**
92+
## <a name="PowerShellProcedure"></a> Use PowerShell
93+
To manually fail over an availability group:
11494
115-
1. Change directory (**cd**) to the server instance that hosts the target secondary replica.
95+
1. Change the directory (**cd**) to the server instance that hosts the target secondary replica.
11696
117-
2. Use the **Switch-SqlAvailabilityGroup** cmdlet.
97+
2. Use the **Switch-SqlAvailabilityGroup** cmdlet.
11898
119-
> [!NOTE]
120-
> To view the syntax of a cmdlet, use the **Get-Help** cmdlet in the [!INCLUDE[ssCurrent](../../../includes/sscurrent-md.md)] PowerShell environment. For more information, see [Get Help SQL Server PowerShell](../../../relational-databases/scripting/get-help-sql-server-powershell.md).
99+
> [!NOTE]
100+
> To view the syntax of a cmdlet, use the **Get-Help** cmdlet in the [!INCLUDE[ssCurrent](../../../includes/sscurrent-md.md)] PowerShell environment. For more information, see [Get help for SQL Server PowerShell](../../../relational-databases/scripting/get-help-sql-server-powershell.md).
121101
122-
The following example manually fails over the *MyAg* availability group to the secondary replica with the specified path.
102+
The following example manually fails over the *MyAg* availability group to the secondary replica with the specified path:
123103
124104
```
125105
Switch-SqlAvailabilityGroup -Path SQLSERVER:\Sql\SecondaryServer\InstanceName\AvailabilityGroups\MyAg
126106
```
127107
128-
**To set up and use the SQL Server PowerShell provider**
108+
To set up and use the SQL Server PowerShell provider:
129109
130-
- [SQL Server PowerShell Provider](../../../relational-databases/scripting/sql-server-powershell-provider.md)
131-
132-
- [Get Help SQL Server PowerShell](../../../relational-databases/scripting/get-help-sql-server-powershell.md)
110+
- [SQL Server PowerShell provider](../../../relational-databases/scripting/sql-server-powershell-provider.md)
111+
- [Get help for SQL Server PowerShell](../../../relational-databases/scripting/get-help-sql-server-powershell.md)
112+
113+
## <a name="FollowUp"></a> Follow up: After you manually fail over an availability group
114+
If you failed over outside the [!INCLUDE[ssFosAuto](../../../includes/ssfosauto-md.md)] of the availability group, adjust the quorum votes of the Windows Server failover clustering nodes to reflect your new availability group configuration. For more information, see [Windows Server failover clustering &#40;WSFC&#41; with SQL Server](../../../sql-server/failover-clusters/windows/windows-server-failover-clustering-wsfc-with-sql-server.md).
133115
134-
## <a name="FollowUp"></a> Follow Up: After Manually Failing Over an Availability Group
135-
If you failed over outside of the [!INCLUDE[ssFosAuto](../../../includes/ssfosauto-md.md)] of the availability group, adjust the quorum votes of the WSFC nodes to reflect your new availability group configuration. For more information, see [Windows Server Failover Clustering &#40;WSFC&#41; with SQL Server](../../../sql-server/failover-clusters/windows/windows-server-failover-clustering-wsfc-with-sql-server.md).
136-
137116
<a name = "ReadScaleOutOnly"><a/>
138117
139-
##Fail over primary replica on read-scale availability group
118+
## Fail over the primary replica on a read-scale availability group
119+
120+
[!INCLUDE[Force failover](../../../includes/ss-force-failover-read-scale-out.md)]
140121
141-
[!INCLUDE[Force Failover](../../../includes/ss-force-failover-read-scale-out.md)]
122+
## See also
142123
143-
## See Also
144-
[Overview of Always On Availability Groups &#40;SQL Server&#41;](../../../database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server.md)
145-
[Failover and Failover Modes &#40;Always On Availability Groups&#41;](../../../database-engine/availability-groups/windows/failover-and-failover-modes-always-on-availability-groups.md)
146-
[Perform a Forced Manual Failover of an Availability Group &#40;SQL Server&#41;](../../../database-engine/availability-groups/windows/perform-a-forced-manual-failover-of-an-availability-group-sql-server.md)
124+
* [Overview of AlwaysOn availability groups &#40;SQL Server&#41;](../../../database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server.md)
125+
* [Failover and failover modes &#40;AlwaysOn availability groups&#41;](../../../database-engine/availability-groups/windows/failover-and-failover-modes-always-on-availability-groups.md)
126+
* [Perform a forced manual failover of an availability group &#40;SQL Server&#41;](../../../database-engine/availability-groups/windows/perform-a-forced-manual-failover-of-an-availability-group-sql-server.md)
147127
148128

0 commit comments

Comments
 (0)