| title | Enable and Disable AlwaysOn Availability Groups (SQL Server) | Microsoft Docs | ||||
|---|---|---|---|---|---|
| ms.custom | |||||
| ms.date | 06/14/2017 | ||||
| ms.prod | sql-server-2014 | ||||
| ms.reviewer | |||||
| ms.technology | high-availability | ||||
| ms.topic | conceptual | ||||
| helpviewer_keywords |
|
||||
| ms.assetid | 7c326958-5ae9-4761-9c57-905972276a8f | ||||
| author | MashaMSFT | ||||
| ms.author | mathoma | ||||
| manager | craigg |
Enabling [!INCLUDEssHADR] is a prerequisite for a server instance to use availability groups. Before you can create and configure any availability group, the [!INCLUDEssHADR] feature must have been enabled on the each instance of [!INCLUDEssNoVersion] that will host an availability replica for one or more availability groups.
Important
If you delete and re-create a WSFC cluster, you must disable and re-enable the [!INCLUDEssHADR] feature on each instance of [!INCLUDEssNoVersion] that hosted an availability replica on the original WSFC cluster.
-
Before you begin:
-
How To:
-
The server instance must reside on a Windows Server Failover Clustering (WSFC) node.
-
The server instance must be running an edition of SQL Server that supports [!INCLUDEssHADR]. For more information, see Features Supported by the Editions of SQL Server 2014.
-
Enable AlwaysOn Availability Groups on only one server instance at a time. After enabling AlwaysOn Availability Groups, wait until the [!INCLUDEssNoVersion] service has restarted before you proceed to another server instance.
For information about additional prerequisites for creating and configuring availability groups, see Prerequisites, Restrictions, and Recommendations for AlwaysOn Availability Groups (SQL Server).
While AlwaysOn Availability Groups is enabled on an instance of [!INCLUDEssNoVersion], the server instance has full control on the WSFC cluster.
Requires membership in the Administrator group on the local computer and full control on the WSFC cluster. When enabling AlwaysOn by using PowerShell, open the Command Prompt window using the Run as administrator option.
Requires Active Directory Create Objects and Manage Objects permissions.
To determine whether AlwaysOn Availability Groups is enabled
-
In Object Explorer, right-click the server instance, and click Properties.
-
In the Server Properties dialog box, click the General page. The Is HADR Enabled property displays one of the following values:
-
True, if AlwaysOn Availability Groups is enabled
-
False, if AlwaysOn Availability Groups is disabled.
-
To determine whether AlwaysOn Availability Groups is enabled
-
Use the following SERVERPROPERTY statement:
SELECT SERVERPROPERTY ('IsHadrEnabled');
The setting of the
IsHadrEnabledserver property indicates whether an instance of [!INCLUDEssNoVersion] is enabled for AlwaysOn Availability Groups, as follows:-
If
IsHadrEnabled= 1, AlwaysOn Availability Groups is enabled. -
If
IsHadrEnabled= 0, AlwaysOn Availability Groups is disabled.
[!NOTE]
For more information about theIsHadrEnabledserver property, see SERVERPROPERTY (Transact-SQL). -
To determine whether AlwaysOn Availability Groups is enabled
-
Set default (
cd) to the server instance (e.g.\SQL\NODE1\DEFAULT) on which you want to determine whether [!INCLUDEssHADR] is enabled. -
Enter the following PowerShell
Get-Itemcommand:Get-Item . | Select IsHadrEnabled
[!NOTE]
To view the syntax of a cmdlet, use theGet-Helpcmdlet in the [!INCLUDEssNoVersion] PowerShell environment. For more information, see Get Help SQL Server PowerShell.
To set up and use the SQL Server PowerShell provider
To enable AlwaysOn, using:
To enable AlwaysOn Availability Groups
-
Connect to the Windows Server Failover Clustering (WSFC) node that hosts the [!INCLUDEssNoVersion] instance where you want to enable AlwaysOn Availability Groups.
-
On the Start menu, point to All Programs, point to [!INCLUDEssCurrentUI], point to Configuration Tools, and click SQL Server Configuration Manager.
-
In SQL Server Configuration Manager, click SQL Server Services, right-click SQL Server (<
instance name>), where <instance name> is the name of a local server instance for which you want to enable AlwaysOn Availability Groups, and click Properties. -
Select the AlwaysOn High Availability tab.
-
Verify that Windows failover cluster name field contains the name of the local failover cluster. If this field is blank, this server instance currently does not support [!INCLUDEssHADR]. Either the local computer is not a cluster node, the WSFC cluster has been shut down, or this edition of [!INCLUDEssCurrent] that does not support [!INCLUDEssHADR].
-
Select the Enable AlwaysOn Availability Groups check box, and click OK.
[!INCLUDEssNoVersion] Configuration Manager saves your change. Then, you must manually restart the [!INCLUDEssNoVersion] service. This enables you to choose a restart time that is best for your business requirements. When the [!INCLUDEssNoVersion] service restarts, AlwaysOn will be enabled, and the
IsHadrEnabledserver property will be set to 1.
To enable AlwaysOn
-
Change directory (
cd) to a server instance that you want to enable for AlwaysOn Availability Groups. -
Use the
Enable-SqlAlwaysOncmdlet to enable AlwaysOn Availability Groups.To view the syntax of a cmdlet, use the
Get-Helpcmdlet in the [!INCLUDEssNoVersion] PowerShell environment. For more information, see Get Help SQL Server PowerShell.[!NOTE]
For information about how to control whether theEnable-SqlAlwaysOncmdlet restarts the [!INCLUDEssNoVersion] service, see When Does a Cmdlet Restart the SQL Server Service?, later in this topic.
To set up and use the SQL Server PowerShell provider
The following PowerShell command enables [!INCLUDEssHADR] on an instance of SQL Server (Computer\Instance).
Enable-SqlAlwaysOn -Path SQLSERVER:\SQL\Computer\Instance -
Before you disable AlwaysOn:
-
To disable AlwaysOn, using:
-
Follow Up: After Disabling AlwaysOn
Important
Disable AlwaysOn on only one server instance at a time. After disabling AlwaysOn Availability Groups, wait until the [!INCLUDEssNoVersion] service has restarted before you proceed to another server instance.
Before you disable AlwaysOn on a server instance, we recommend that you do the following:
-
If the server instance is currently hosting the primary replica of an availability group that you want to keep, we recommend that you manually fail over the availability group to a synchronized secondary replica, if possible. For more information, see Perform a Planned Manual Failover of an Availability Group (SQL Server).
-
Remove all local secondary replicas. For more information, see Remove a Secondary Replica from an Availability Group (SQL Server).
To disable AlwaysOn
-
Connect to the Windows Server Failover Clustering (WSFC) node that hosts the [!INCLUDEssNoVersion] instance where you want to disable AlwaysOn Availability Groups.
-
On the Start menu, point to All Programs, point to [!INCLUDEssCurrentUI], point to Configuration Tools, and click SQL Server Configuration Manager.
-
In SQL Server Configuration Manager, click SQL Server Services, right-click SQL Server (<
instance name>), where <instance name> is the name of a local server instance for which you want to disable AlwaysOn Availability Groups, and click Properties. -
On theAlwaysOn High Availabilitytab, deselect the Enable AlwaysOn Availability Groups check box, and click OK.
[!INCLUDEssNoVersion] Configuration Manager saves your change and restarts the [!INCLUDEssNoVersion] service. When the [!INCLUDEssNoVersion] service restarts, AlwaysOn will be disabled, and the
IsHadrEnabledserver property will be set to 0, to indicate that AlwaysOn Availability Groups is disabled. -
We recommend that you read the information in Follow Up: After Disabling AlwaysOn, later in this topic.
To disable AlwaysOn
-
Change directory (
cd) to a currently-enabled server instance that you want to disenable for AlwaysOn Availability Groups. -
Use the
Disable-SqlAlwaysOncmdlet to enable AlwaysOn Availability Groups.For example, the following command disables AlwaysOn Availability Groups on an instance of SQL Server (Computer\Instance). This command requires restarting the instance, and you will be prompted to confirm this restart.
Disable-SqlAlwaysOn -Path SQLSERVER:\SQL\Computer\Instance
[!IMPORTANT]
For information about how to control whether theDisable-SqlAlwaysOncmdlet restarts the [!INCLUDEssNoVersion] service, see When Does a Cmdlet Restart the SQL Server Service?, later in this topic.To view the syntax of a cmdlet, use the
Get-Helpcmdlet in the [!INCLUDEssNoVersion] PowerShell environment. For more information, see Get Help SQL Server PowerShell.
To set up and use the SQL Server PowerShell provider
After you disable AlwaysOn Availability Groups, the instance of [!INCLUDEssNoVersion] must be restarted. SQL Configuration Manager restarts the server instance automatically. However, if you used the Disable-SqlAlwaysOn cmdlet, you will need to restart the server instance manually. For more information, see sqlservr Application.
On the restarted server instance:
-
Availability databases do not start up at SQL Server startup, making them inaccessible.
-
The only supported AlwaysOn [!INCLUDEtsql] statement is DROP AVAILABILITY GROUP. CREATE AVAILABILITY GROUP, ALTER AVAILABILITY GROUP, and the SET HADR options of ALTER DATABASE are not supported.
-
[!INCLUDEssNoVersion] metadata and [!INCLUDEssHADR] configuration data in WSFC are unaffected by disabling AlwaysOn Availability Groups.
If you permanently disable AlwaysOn Availability Groups on every server instance that hosts an availability replica for one or more availability groups, we recommend that you complete the following steps:
-
If you did not remove the local availability replicas before disabling AlwaysOn, delete (drop) each availability group for which the server instance is hosting an availability replica. For information about deleting an availability group, see Remove an Availability Group (SQL Server).
-
To remove the metadata left behind, delete (drop) each affected availability group on a server instance that is part of the original WSFC cluster.
-
Any primary databases continue to be accessible to all connections but the data synchronization between the primary and secondary databases stops.
-
The secondary databases enter the RESTORING state. You can delete them, or you can restore them by using RESTORE WITH RECOVERY. However, restored databases are no longer participating in availability-group data synchronization.
On a server instance that is currently running, using Enable-SqlAlwaysOn or Disable-SqlAlwaysOn to change the current AlwaysOn setting could cause the SQL Server service to restart. The restart behavior on depends on the following conditions:
| -NoServiceRestart parameter specified | -Force parameter specified | Is the [!INCLUDEssNoVersion] service restarted? |
|---|---|---|
| No | No | By default. But the cmdlet prompts you as follows: To complete this action, we must restart the SQL Server service for server instance '<instance_name>'. Do you want to continue? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): If you specify N or S, the service is not restarted. |
| No | Yes | Service is restarted. |
| Yes | No | Service is not restarted. |
| Yes | Yes | Service is not restarted. |
Overview of AlwaysOn Availability Groups (SQL Server)
SERVERPROPERTY (Transact-SQL)