Monday, 20 February 2017

AlwaysOn Availability Groups: Step by Step Setup

blogger tricks

An availability group supports a failover environment for a discrete set of user databases, known as availability databases, that fail over together. An availability group supports a set of primary databases and one to eight sets of corresponding secondary databases. Secondary databases are not backups. Continue to back up your databases and their transaction logs on a regular basis.

To read overview on always on availability groups click [here]

Prerequisites required to enable SQL Server 2012 AlwaysOn Availability Groups Feature.

  • Get the operating system installed, patched and configured on all participating nodes
  • See either Windows Update or an internal Windows Server Update Services (WSUS) server to get all of the required Windows Updates downloaded and installed 
  • Dedicated domain user account be created for use by the SQL Server service. This should just be a regular or domain account 
  • Having separate accounts for SQL Agent service, SSRS, SSIS & SSRS. Having separate account is more secure and resilient, since a problem with one account won’t affect all of the SQL Server Services 
  • Ensure the password not temporary and there is complex password
  • Both SQL & OS Editions, Versions should be at same level on all participating nodes
  • All replicas in your AlwaysOn group must be in the same windows domain. They must be able to communicate with each other.
  • Always on availability groups is only supported in Enterprise edition starting from SQL server 2012 ( except SQL 2016 it supports basic availability group in standard edition)
  • Recommend to have same collation on all replicas
  • SQL Server port must be opened at firewall level for communication between replicas
  • Create shared network share on all participating nodes
  • You need to install 3.5.1 or greater on all participating nodes
  • Make sure your databases are in Full Recovery Mode, not Simple or Bulk Logged
  • Databases included in your AlwaysOn group must be user databases. System databases cannot participate in AlwaysOn Availability Groups.
  • Read-only databases cannot belong to an AlwaysOn group
  • Databases may only belong to one availability group at a time
  • Make sure full backups of each of your databases are made prior to installing AlwaysOn
  • No cluster shared volume is required for Always on, it can be configured in local disks
  • Make sure you have a seperate NIC's for public and private communication
  • Additional NIC is required if you want to isolate always on replication traffic to dedicated NIC
  • Make sure you have two free IP's each for windows cluster IP and Always on listener IP

AlwaysOn Availability Groups require a Windows Server Failover Cluster, we first need to add the Windows Failover Cluster Feature to all the nodes running the SQL Server instances that we will configure as replicas

To know how to install failover cluster click [here]

We have two node windows failover cluster SQL1 & SQL2 already setup as shown in below screenshot.

Once you have installed failover cluster we can now proceed with enabling the AlwaysOn Availability Groups feature in SQL Server 2012. This needs to be done on all of the SQL Server instances that you will configure as replicas in your Availability Group.

How to Enable SQL Server 2012 AlwaysOn Availability Groups Feature

Default standalone SQL instances installed on nodes SQL1 & SQL2

Step 1:

Open SQL Server Configuration Manager. Double-click the SQLServer (MSSQLSERVER) service to open the Properties dialog box.

In the Properties dialog box, select the AlwaysOn High Availability tab. Check the Enable AlwaysOn Availability Groups check box. This will prompt you to restart the SQL Server service. Click OK

In below screenshot, AONTESTWFCS01 is the windows cluster name. SQL1 and SQL2 are nodes.

Step 2:

Restart the SQL Server service

Create and Configure SQL Server 2012 AlwaysOn Availability Groups

Step 3:

To create and configure a SQL Server 2012 AlwaysOn Availability Group,

Open SQL Server Management Studio. Connect to the SQL Server instance

In Object Exporer, expand the AlwaysOn High Availability folder. Right-click on the Availability Groups folder and select the New Availability Group Wizard… option. This will launch the New Availability Group Wizard.
Step 4:

In the Introduction page, click Next.

In the Specify Availability Group Name page, enter the name of the Availability Group in the Availability group name: field. Click Next.

Step 5:

In the Select Databases page, select the checkbox beside the database that you want to include in your Availability Group. The databases have to be in Full recovery model prior to joining them in the Availability group. Click Next.

In below screenshot, we have selected AGTEST database to Always on availability.

Step 6:

In the Specify Replicas page, under the Replicas tab, click the Add Replicas button and connect to the other SQL Server instances that you joined as nodes in your Windows Server Failover Cluster.

Configure the following options:
  • Automatic Failover
  • Synchornous commit
  • Readable secondary 
In below screenshot, specified replicas SQL1 & SQL2.
Step 7:

In the Endpoints tab, verify that the port number value is 5022 and endpoint name Hadr_endpoint. 

Step 8:

In below screenshot, Selected backup preferences as shown in below screenshot.

Step 9:

In the Listener tab, select the Create an availability group listener option. Enter the following details.

Listener DNS name: AGLIS01
Port: 16333
Listener IP Address:

Click the Add… button to provide an IP address. In the Add IP Address dialog box, enter your preferred virtual IP address in the IPv4 Address field. Click OK. Click Next.

Step 10:

In the Select Initial Data Synchronization page, select the Full option. Provide a shared folder that is accessible the replicas and that the SQL Server service account used by both replicas has Write permissions to. This is just a temporary file share to store the database backups that will be used to initialize the databases in an Availability group. If you are dealing with large databases, it is recommended that you manually initialize the databases prior to configuring them as your network bandwidth may not be able to accommodate the size of the database backups. Click Next.

Step 11:

In the Validation page, verify that all validation checks return successful results. Click Next.

Step 12:

In the Summary page, verify all configuration settings and click Finish. This will create and configure the AlwaysOn Availability Group and join the databases.


  1. Hi got a question on this "Always on availability groups is only supported in Enterprise edition starting from SQL server 2012 ( except SQL 2016 it supports basic availability group in standard edition)" what I read it says that on Standard it's up to 2 nodes but that mean it's only the failover cluster part???

    1. Yes it supports only one replica. Basic availability groups enable a primary database to maintain a single replica. This replica can use either synchronous-commit mode or asynchronous-commit mode.

      To know limitation of basic availability group check below article.

  2. Hi Ganapathi,

    It is again very nice article.

    When we create an AlwaysOn, will it create a separate instance and database? Sorry it may be silly.


    1. Hi Rajan,

      No. it is a standalone instance and you have to add database into availability groups.

      HA availability group is a group of databases that fail over together.

  3. HI Ganapati,

    Its AWSOMEEEEE...Thanks man.

  4. Hi Ganpati,

    I have a query, We hare a requirement to have SQL high Availability without Shared Drive. With reference to your blog we have configured Windows Failover Cluster on both the servers. Now the question is :
    1. What installation type we have to use during installation Standalone or SQL Cluster Node installation?
    2. If we go for SQL Cluster Node installation we are getting error like " No Storage Device" on Server.
    3. If standalone both SQL servers instance need to keep same?
    Please suggest which option we have to select.

    1. SQL cluster installation works only on shared drive. Based on your requirement, you can install standalone instances of SQL Server and enable always on availability groups for SQL HA. Yes for always on AG, both instance should be of Same edition i.e.. Enterprise edition only