You are on page 1of 17

SQL Server Denali - AlwaysON (HADR):

Step-by-Setup setup guide

Balmukund 

As you might be aware that SQL Server Code-Named “Denali” has introduced a new feature called Always ON for

enhancing the availability of user database in an enterprise environment. In simple terms, AlwaysON is a high-

availability and disaster recovery solution, which will enable you maximize availability of your critical user databases

by use of “availability groups”

WARNING: The blog-post is based on pre-release software so things could change. For more details on CTP,

please refer SQL Server Code-Named "Denali" CTP1 Release Notes

So what are “Availability Groups”?

Availability groups are set of failover partners (a.k.a availability replicas) to provide high availability to user database

in Denali. Sure, this is lot more in depth and I suggest reading DenaliBooks-on-line for details.

In this blog post, I will guide you on how to configure AlwaysON – STEP-BY-STEP? Lets get going then !

Step 1. Windows OS and Cluster Configuration

a. For the purpose of testing, I have created a Windows 2008R2 two NODE cluster on virtual machine using Hyper-V

and a Domain Controller

Machine configurations:

Machine Name Role OS IP Address

INDNUKE- Domain Controller Windows 2008R2 192.168.1.1


BANGALORED
C

INDNUKE- Cluster Node 1 Windows 2008R2 192.168.1.2 Public 


DELHI X.X.10.1 
Heartbeat

INDNUKE- Cluster Node 2 Windows 2008R2 192.168.1.3 Public 


MUMBAI X.X.10.2 
Heartbeat

If in case you need step-by-step guide on setting up windows cluster using Hyper-V (Guest Clustering), please refer

my team blog:

http://blogs.msdn.com/blakhani/archive/2010/04/01/how-to-install-clustered-sql-server-2008-on-
windows-2008-cluster-using-hyper-v-guest-clustering-part-1.aspx 
http://blogs.msdn.com/blakhani/archive/2010/04/28/how-to-install-clustered-sql-server-2008-on-
windows-2008-cluster-using-hyper-v-guest-clustering-part-2.aspx

Step 2. Install “Standalone” Denali instance on both the nodes

Yes, you’ve heard it right. AlwaysON is NOT a clustered SQL Server Instance. As such a standalone SQL

Server setup is required on both the clustered nodes.

I’ve installed 2 DEFAULT instances on both the clustered nodes as below:

INDNUKE-DELHI\MSSQLSERVER

INDNUKE-MUMBAI\MSSQLSERVER

Step 3. Enable AlwaysON feature on both the instances

•Open SQL Server Configuration Manager 

•Select SQL Server Services 


•Right-click on your SQL Server, in my case SQL Server (MSSQLSERVER) and select Properties 

•Select SQL HADR TAB and check "Enable SQL HADR service"

Note: SQL Server service needs to be re-started for changes to take affect

Step 4. Create a sample database on both SQL Server Instances

For this testing, I will be using AdventureWorks sample database

Step 5. Create Availability Group

•Choose any one instance to become PRIMARY (say INDNUKE-DELHI\MSSQLSERVER) 

•Open SQL Server Management Studio on INDNUKE-DELHI\MSSQLSERVER 

•Expand Management folder 

•Right-click Availability Groups and select New Availability Group


•Click Next on Introduction Screen

•Provide a name to Availability Group

•Select the user database to be added to Availability Group


 

•Specify Replicas – Add the other instances (INDNUKE-MUMBAI\MSSQLSERVER) to assume the role of secondary

of this user database


 

•Optionally, you can specify endpoint details (similar to database mirroring) or leave them default
 

•Summary Screen
 

•Result Screen
 

IMP: Once done, you will be able to see the Availability Group as a Cluster Resource in Windows Server

Failover Cluster Manager

Step 6. Start Data Synchronization

•This step will allow you to synchronize your user PRIMARY and SECONDARY server by taking backup of user

database and restoring this on secondary server 


 

•Specify a shared location, where both SQL Server start-up accounts has read/write access and press OK

•Once synchronization completes, expand the tree and you will be able to see the Availability Replicas (along with

current role ) and Availability Databases

Step 7. Test the Availability Groups

•To understand how failover functions in AlwaysON, follow simple steps

1. Create a simple table (can use below script) on PRIMARY (INDNUKE-DELHI) and insert some rows (can use

below script)

Use AdventureWorks 
GO

CREATE TABLE [dbo].[New_Table]( 

    [ID][int] NULL, 

    [NAME] [varchar](50) NULL 

) ON [PRIMARY] 

GO

INSERT INTO dbo.New_Table values (5001, 'NORTH') 

GO
SELECT * from dbo.New_Table 

GO

2. Then, connect to SECONDRY (INDNUKE-MUMBAI) and try selecting the rows. This will work!!

Step 8. Test the Failover

•To FAILOVER, follow below steps


Before FAILOVER

After FAILOVER – server roles will change

 Conclusion,

AlwaysON by design looks similar to database mirroring, but is actually a combination of both databases mirroring

and clustering. The goal is to maximize the database availability and also give benefits of disaster recovery. And we
term this – AlwaysON!!!!

Varun Dhawan 

Support Engineer ,Microsoft SQL Server Support

Reviewed by 

Balmukund Lakhani, Nikesh Mhatre 

Tejas Shah, Amit Banerjee (SQL Server Escalation Services)


Leave a Comment

 Name

 Comment

 Post

Comments

 HeatherK
20 Dec 2010 7:09 AM

What do you mean "Yes, you’ve heard it right. AlwaysON is NOT a clustered SQL Server Instance. As such a
standalone SQL Server setup is required on both the clustered nodes."  The BOL for Denali CTP1 say that you can
either use a clustered instance or a standalone instance.  Why would you want to use two standalone SQL Server
instances on 2 nodes in the same cluster?  What would happen when there is a failover event within the cluster?

 Varun_SQL
22 Dec 2010 3:36 AM

Hi Heather,

Thanks for pointing this out. Seems we missed it at first place....so here’s the updated details:

1. For configuring AlwaysON, we can we can either use a failover cluster instances or stand-alone instances.

2. The "Two" standalone instances mentioned in this post are just an example for an easier demonstration.

So assuming there are 2 standalone instances running on Windows Server Failover Clustering. In the event of cluster
failover, there will be a failover from Primary to Secondary replica.

Regards,

Varun
 Uri Dimant
2 Jan 2011 4:41 AM

Hello Varun

To force FAILOVER do you click on the secondary server? Why not on the primary server?

 ColinM
11 Mar 2011 3:08 AM

Hi Varun,

I've seen it suggested (www.brentozar.com/.../sql-server-denali-database-mirroring-rocks) that you'll be able to


run your backup from a replica.  Do you know anything more about how this works? - for eg, would BACKUP LOG on
the secondary replica cause the log file on the primary to be appropriately truncated?

Thanks,

Colin.

 Pawan
1 Jun 2011 11:09 PM

Hello Varun,

Thanks for a very informative post on AlwaysOn. The setup screen shots are really helpful in understanding the
HARD setup.

- Pawan | SQL Server DBA

 Varun_SQL
9 Aug 2011 4:26 AM

Hello Colin

First apologies for a late reply as I've been busy leveling some new assignments.
Answer to your questions is YES, it’s possible to take LOG backups on a secondary replica in an AlwaysOn (HADR)
configuration. A ‘BACKUP LOG’ T-SQL will work as usual on secondary replica/s and all such log backups WILL
TRUNCATE T-LOG file on primary.

Hope this answers your query.

Varun

 Varun_SQL
9 Aug 2011 4:40 AM

Hi Uri

A force causes the secondary replica to which the availability group was failed over becomes the new primary replica.
This seems purely a by-design thing that such force failover is initiated from a secondary replica of the availability
group.

Varun

 mahalingam
1 Jan 2012 10:30 PM

Hi Bala,

Thanks for the innovative information . could you please describe to us to take the backup on secondary
replica.Thanks

 Nakul's Blog
11 Feb 2012 9:31 AM

As you know, I am documenting my experience at the Tech Ed 2011 (India) held from March 23-25, 2011 at

 JunDba
10 Mar 2012 9:40 PM

Hi,
Is it possible to create alwayson for database in an instance in 3 node cluster with standalone as sceondary server

 Balmukund
14 Mar 2012 10:06 PM

JunDba,

All machine participating in AlwaysOn MUST be part of same windows cluster.

 riya sharma
17 Apr 2012 7:01 AM

can uable to change group ID of availabilty group

 Varun_SQL
5 Jul 2012 4:16 AM

@Riya

Why do you need to change the ID (which is a 'metadata') of an Availability Group?

 Manish
31 Aug 2012 12:55 AM

It will not work on SQL Failover Cluster, Only Windows Failover Cluster is required and both the node should have
same drive later.

 reshma
13 Jul 2013 3:14 PM

Thanks for the post.

 © 2013 Microsoft Corporation.


 
 Terms of Use 
 Trademarks 
 Privacy & Cookies 
 Report Abuse 
 5.6.426.415

You might also like