MSDN Documentation

Microsoft Developer Network

SQL Server Always On Availability Groups Setup

This guide provides step-by-step instructions for setting up SQL Server Always On Availability Groups, ensuring high availability and disaster recovery for your critical databases.

Prerequisites

Before you begin the setup process, ensure the following prerequisites are met:

Step 1: Enable Always On Availability Groups Feature

On each SQL Server instance that will participate in an availability group, you must enable the Always On Availability Groups feature.

  1. Open SQL Server Configuration Manager.
  2. Navigate to SQL Server Services.
  3. Right-click on your SQL Server instance and select Properties.
  4. Go to the Always On High Availability tab.
  5. Check the box for Enable Always On Availability Groups.
  6. Click OK.
  7. Restart the SQL Server service for the changes to take effect.

Note:

You must restart the SQL Server service after enabling this feature.

Step 2: Configure Windows Server Failover Cluster (WSFC)

Ensure your WSFC is properly configured and healthy. This typically involves:

You can use the Failover Cluster Manager console for these tasks.

Step 3: Create an Availability Group

Once the feature is enabled and WSFC is ready, you can create the availability group.

  1. In SQL Server Management Studio (SSMS), connect to the primary replica instance.
  2. Navigate to Object Explorer > Always On High Availability.
  3. Right-click on Availability Groups and select New Availability Group Wizard....
  4. Follow the wizard prompts:
    • Specify Availability Group Name: Provide a unique name for your availability group.
    • Select Databases: Choose the user databases you want to include. Ensure they are in the FULL recovery model.
    • Specify Replicas: Add secondary replicas and configure their roles (e.g., Synchronous commit, Automatic failover, Readable secondary).
    • Select Data Synchronization: Choose your preferred method for initial data synchronization (e.g., Automatic seeding, Manual seeding with backup/restore, Join only).
    • Validation: The wizard will perform validation checks. Resolve any warnings or errors.
    • Summary and Finish: Review your configuration and click Finish.

Tip:

For automatic seeding, ensure that the SQL Server service account on each replica has read/write permissions to the specified data directories.

Step 4: Configure Listener

An availability group listener provides a virtual network name (VNN) and virtual IP address (VIP) that client applications connect to, abstracting the underlying replica instances.

  1. In SSMS, expand your newly created Availability Group.
  2. Right-click on Availability Group Listeners and select Add Listener....
  3. Provide a DNS Name for the listener.
  4. Specify the Port (default is 1433).
  5. Add one or more IP Addresses for the listener, ensuring they are in the same subnet as your cluster nodes.
  6. Click OK.

Step 5: Testing and Verification

After setup, thoroughly test your availability group:

Common Issues and Troubleshooting

Refer to the following table for common issues and their resolutions:

Issue Possible Cause Resolution
Databases not synchronized Network connectivity problems, Firewall blocking ports, Incorrect recovery model. Check network, firewall rules, ensure databases are in FULL recovery model, verify SQL Server Browser service.
Listener not accessible Incorrect IP configuration, DNS issues, Firewall blocking listener port. Verify IP address and subnet, ensure DNS records are created, check firewall rules for the listener port.
Failover fails WSFC issues, permissions problems, resource constraints. Check WSFC health, verify SQL Server service account permissions, examine cluster logs.

Warning:

Always perform failover tests during maintenance windows to minimize potential impact on production workloads.

For more in-depth information, consult the official SQL Server Always On Availability Groups documentation.