Getting Started with AlwaysOn Availability Groups (SQL Server)
Updated: March 7, 2016
Applies To: SQL Server 2016
This topic introduces the steps for configuring instances of SQL Server 2016 to support AlwaysOn Availability Groups and for creating, managing, and monitoring an availability group.
Before you create your first availability group, we recommend that you read the following topics:
Enable AlwaysOn Availability Groups. The AlwaysOn Availability Groups feature must be enabled on every instance of SQL Server 2016 that is to participate in an availability group.
Prerequisites: The host computer must be a Windows Server Failover Clustering (WSFC) node.
For information about the other prerequisites, see "SQL Server Instance Prerequisites and Restrictions" in Prerequisites, Restrictions, and Recommendations for AlwaysOn Availability Groups (SQL Server).
Create database mirroring endpoint (if none). Ensure that each server instance possesses a database mirroring endpoint. The server instance uses this endpoint to receive AlwaysOn Availability Groups connections from other server instances.
To determine whether database mirroring endpoint exists: sys.database_mirroring_endpoints
For Windows Authentication. To create a database mirroring endpoint, using:
For certificate authentication. To create a database mirroring endpoint, using:Transact-SQL
Create the availability group. Create the availability group on the instance of SQL Server that hosts the databases to be added to the availability group.
Minimally, create the initial primary replica on the instance of SQL Server where you create the availability group. You can specify from one to four secondary replicas. For information about availability group and replica properties, see CREATE AVAILABILITY GROUP (Transact-SQL).
We strongly recommend that you create an availability group listener.
Prerequisites: The instances of SQL Server that host availability replicas for a given availability group must reside on separate nodes of a single WSFC cluster. The only exception is that while being migrated to another WSFC cluster, an availability group can temporarily straddle two clusters.
For information about the other prerequisites, see "Availability Group Prerequisites and Restrictions", "Availability Database Prerequisites and Restrictions", and "SQL Server Instance Prerequisites and Restrictions" in Prerequisites, Restrictions, and Recommendations for AlwaysOn Availability Groups (SQL Server).
To create an availability group you can use any of the following tools:
Join secondary replicas to the availability group. Connect to each instance of SQL Server 2016 that is hosting a secondary replica, and join the local secondary replica to the availability group.
Tip: If you use the New Availability Group Wizard, this step is automated.
Prepare secondary databases. On every server instance that is hosting a secondary replica, restore backups of the primary databases using RESTORE WITH NORECOVERY.
Tip: The New Availability Group Wizard can prepare the secondary databases for you. For more information, see "Prerequisites for using full initial data synchronization" in Select Initial Data Synchronization Page (AlwaysOn Availability Group Wizards).
Join secondary databases to the availability group. On every server instance that is hosting a secondary replica, join each local secondary database to the availability group. On joining the availability group, a given secondary database initiates data synchronization with the corresponding primary database.
Tip: The New Availability Group Wizard can perform this step if every secondary database exists on every secondary replica.
Create an availability group listener. This step is necessary unless you already created the availability group listener while creating the availability group.
Give the listener's DNS host name to application developers. Developers needs to specify this DNS name in the connection strings to direct connection requests to the availability group listener. For more information, see Availability Group Listeners, Client Connectivity, and Application Failover (SQL Server).
"Follow Up: After Creating an Availability Group Listener" in Create or Configure an Availability Group Listener (SQL Server)
Configure Where Backup Jobs. If you want to perform backups on secondary databases, you must create a backup job script that takes the automated backup preference into account. Create a script for each database in the availability group on every server instance that hosts an availability replica for the availability group.
"Follow Up: After Configuring Backup on Secondary Replicas" in Configure Backup on Availability Replicas (SQL Server)
For information about availability group and replica properties, see CREATE AVAILABILITY GROUP (Transact-SQL).
Managing existing availability groups involves one or more of the following tasks:
Modify the flexible failover policy of the availability group to control the conditions that cause an automatic failover. This policy is relevant only when automatic failover is possible.
Perform a planned manual failover or a forced manual failover (with possible data loss), typically called forced failover. For more information, see Failover and Failover Modes (AlwaysOn Availability Groups).
Use a set of predefined policies to view the health of an availability group and its replicas and databases.
Add or remove a secondary replica.
Suspend or resume an availability database. Suspending a secondary database keeps at its current point in time until you resume it.
Add or remove a database.
Reconfigure or create an availability group listener.
Delete an availability group.
Troubleshoot add file operations. This might be required if the primary database and a secondary database have different file paths.
Alter availability replica properties.
To monitor the properties and state of an AlwaysOn availability group you can use the following tools.
System Center Monitoring pack for SQL Server
The Monitoring pack for SQL Server (SQLMP) is the recommended solution for monitoring availability groups, availability replica and availability databases for IT administrators. Monitoring features that are particularly relevance to AlwaysOn Availability Groups include the following:
Automatic discoverability of availability groups, availability replicas, and availability database from among hundreds of computers. This enables you to easily keep track of your AlwaysOn Availability Groups inventory.
Fully capable System Center Operations Manager (SCOM) alerting and ticketing. These features provide detailed knowledge that enables faster resolution to a problem.
A custom extension to AlwaysOn Health monitoring using Policy Based management (PBM).
Health roll ups from availability databases to availability replicas.
Custom tasks that manage AlwaysOn Availability Groups from the System Center Operations Manager console.
To download the monitoring pack (SQLServerMP.msi) and SQL Server Management Pack Guide for System Center Operations Manager (SQLServerMPGuide.doc), see:
AlwaysOn Availability Groups catalog and dynamic management views provide a wealth of information about your availability groups and their replicas, databases, listeners, and WSFC cluster environment.
SQL Server Management Studio
The Object Explorer Details pane displays basic information about the availability groups hosted on the instance of SQL Server to which you are connected.
Tip: Use this pane to select multiple availability groups, replicas, or databases and to perform routine administrative tasks on the selected objects; for example, removing multiple availability replicas or databases from an availability group.
SQL Server Management Studio
Properties dialog boxes enable you to view the properties of availability groups, replicas, or listeners and, in some cases, to change their values.
The SQLServer:Availability Replica performance object contains performance counters that report information about availability replicas.
The SQLServer:Database Replica performance object contains performance counters that report information about the secondary databases on a given secondary replica.
The SQLServer:Databases object in SQL Server contains performance counters that monitor transaction log activities, among other things. The following counters are particularly relevant for monitoring transaction-log activity on availability databases: Log Flush Write Time (ms), Log Flushes/sec, Log Pool Cache Misses/sec, Log Pool Disk Reads/sec, and Log Pool Requests/sec.
Video—Introduction to AlwaysOn: Microsoft SQL Server Code-Named "Denali" AlwaysOn Series,Part 1: Introducing the Next Generation High Availability Solution
AlwaysOn Availability Groups (SQL Server)
Overview of AlwaysOn Availability Groups (SQL Server)
Configuration of a Server Instance for AlwaysOn Availability Groups (SQL Server)
Creation and Configuration of Availability Groups (SQL Server)
Monitoring of Availability Groups (SQL Server)
Overview of Transact-SQL Statements for AlwaysOn Availability Groups (SQL Server)
Overview of PowerShell Cmdlets for AlwaysOn Availability Groups (SQL Server)