Professional Documents
Culture Documents
Before we get started, we need to talk about something. Im going to be using the C word thats right,
Clustering. Deep, calming breaths. Relax. We can do this, you and me. This isnt the old-school clustering with
shared disks, heartbeat networks, and hardware compatibility lists. This is just another feature youre going to
add to your servers, click a few buttons, and move right on to more important things.
If the production server dies, I need to fail over automatically to a second server in the same
Chicago datacenter. (This also means the production and secondary servers cant be on the same SAN,
because SANs do fail.)
If the datacenter goes down, I need to fail over to a DR datacenter o site in Portland. The business
is okay with losing some data in the event of a failure that large, and theyre okay with this failover being
a manual process.
The BI team wants to run reports on the live database with as little delay as possible. They know they
should be building a separate warehouse, but theyre too lazy busy, and they want this to work right
now.
Backups need to run faster, and ideally, I dont want to run backups on my main production server.
To solve this, Im going to implement four SQL Servers with Availability Groups. The four servers will be:
SQL2012PROD1 the primary production SQL Server in Chicago. Data will be stored on a SAN.
SQL2012PROD2 the secondary production SQL Server in Chicago. Its located in the next rack over,
and its got all local storage so that we can tolerate a SAN failure without changing datacenters. Well be
doing synchronous commits between SQL2012PROD1 and SQL2012PROD2, which means I do still need
fast storage on #2 a good t for SSDs.
SQL2012DR1 an o site SQL Server in Portland. Because the business is okay with some data loss in
1 of 15 10/21/2016 8:38 PM
How to Set Up SQL Server Denali Availability Groups https://www.brentozar.com/archive/2011/07/how-set-up-sql-server-denal...
SQL2012DR1 an o site SQL Server in Portland. Because the business is okay with some data loss in
the event of a complete Chicago datacenter failure, well be doing asynchronous commits to this server.
SQL2012RPT1 a read-only SQL Server in Chicago. It can be on any storage (SAN or local). Well be
doing asynchronous commits here, which means we might be running 5-60 seconds behind depending
on load, but thats still more than current enough for the BI teams reports. After hours, when users
arent running reports, well run full backups from this server.
Windows Enterprise is required due to the clustering features, but they dont have to be beefy machines in
my lab, Im using VMs with 2GB of RAM.
Each server needs the .NET Framework 3.5.1 feature and the Failover Clustering feature already installed. To
install these features, go into Server Manager, Features, and click Add Feature. In the Add Features wizard,
check the boxes for .NET Framework 3.5.1 and Failover Clustering:
2 of 15 10/21/2016 8:38 PM
How to Set Up SQL Server Denali Availability Groups https://www.brentozar.com/archive/2011/07/how-set-up-sql-server-denal...
After those two features are installed on all of our servers, we need to con gure the cluster. Go into Control
Panel, Administrative Tools, Failover Cluster Manager. Click Validate a Con guration, and enter the names for
your SQL Servers.
Note that all four of my servers are in the same domain. You cant use servers in di erent AD forests here.
Click Next through the wizard, and youll be asked what tests you want to run. I run all tests every time, but
technically, you could skip the storage tests if youre only using Availability Groups. These servers will not be
sharing storage, so I dont need to test whether any of them can see each others drives. If you run all tests,
youll see warnings in the Storage section:
3 of 15 10/21/2016 8:38 PM
How to Set Up SQL Server Denali Availability Groups https://www.brentozar.com/archive/2011/07/how-set-up-sql-server-denal...
Whether you pass or fail, click the View Report button to get more insight on your servers. A detailed HTML
report pops up to give you the skinny:
Network Warnings
The Network section of validation is giving me warnings because Ive got a few single points of failure. Each of
my servers only has one network card and no network teaming. If a network card went bad, if someone
4 of 15 tripped over a patch cable, or if somebody assigned an IP address that duplicated my SQL Servers, then
10/21/2016 8:38 PM
How to Set Up SQL Server Denali Availability Groups https://www.brentozar.com/archive/2011/07/how-set-up-sql-server-denal...
my servers only has one network card and no network teaming. If a network card went bad, if someone
tripped over a patch cable, or if somebody assigned an IP address that duplicated my SQL Servers, then
whammo, one of my nodes would go down. In a real production environment, youd want to address these
issues.
If you got errors that you want to change, go x them and rerun validation. Otherwise, if you dont see any
showstopper errors, close the validation report and click the Create the cluster now using the validated
nodes link.
The clusters name is not the name of the SQL Server. Thats a really important distinction to remember. A
restaurant might have a lot of waiters, but it only has one manager. Your cluster may end up with several
5 of 15 10/21/2016 8:38 PM
How to Set Up SQL Server Denali Availability Groups https://www.brentozar.com/archive/2011/07/how-set-up-sql-server-denal...
The clusters name is not the name of the SQL Server. Thats a really important distinction to remember. A
restaurant might have a lot of waiters, but it only has one manager. Your cluster may end up with several
di erent instances of SQL Server down the road, but theres only one manager resource for the cluster. The
manager is the one you call when theres a problem with your waiter. If SQL Server is serving us ies in our
database, were going to call the manager. The rest of the time, we can pretty much forget that the manager
even exists.
In my example, Im naming my cluster SQL2012Cluster1. Im only naming it that because all of my machines
are named SQL2012*. Your naming scheme may vary, but I just wanna drive that point home that the cluster
name doesnt really have anything to do with SQL Server.
After the wizard nishes, Failover Cluster Manager will show our newly created cluster with four nodes, a
network, and no services or applications.
What a Cluster
Yes, installing the Failover Clustering feature really is as easy as checking a box and clicking next-next-next.
Now, dont get me wrong, were going to have a few more things to do down the road, but take a moment
here to appreciate just how far Windows has come in the last ten years.
Download SQL Server 2012 Evaluation Edition and start the setup on one of the Windows machines. The very
rst screen in setup is just a little tricky because it o ers one link for New SQL Server stand-alone installation
and another for New SQL Server failover cluster installation. The one you want is stand-alone. You can
indeed do clustering with 2012, but for our solution, were using Availability Groups by themselves.
Installation Choices
In the Feature Selection step, the only feature you absolutely need is Database Engine, but heres what I
choose for lab boxes:
7 of 15 10/21/2016 8:38 PM
How to Set Up SQL Server Denali Availability Groups https://www.brentozar.com/archive/2011/07/how-set-up-sql-server-denal...
In real life, I wouldnt include Distributed Replay on my production servers, but in a 2012 lab environment, its a
fun feature to start playing with. Distributed Replay holds the promise of making load testing easier.
In the Server Con guration step, specify a domain account for SQL Server to use. In my SQL Server setup
checklist, I explain why you should use a di erent domain account per instance. (Im not so anal-retentive as to
use a di erent account per service per instance, though.) Using domain accounts will make it easier for us to
let each SQL Server instance connect to the other instances. Note that if youre using Kerberos, or plan to
later, you should use the same service account for all instances in the same AvailabilityGroup.
The screenshot shows that I use the server name as part of the service account name. My personal naming
standard is:
svc all my service accounts start with this so I can quickly pick them out of AD
MachineName because I use a di erent account per Windows machine for each service
ServiceName because I might be running multiple services on the same Windows box
So in the example below, Im using LAB\svcSQL2012PROD1_SQL for the database service accounts on
SQL2012PROD1.
8 of 15 10/21/2016 8:38 PM
How to Set Up SQL Server Denali Availability Groups https://www.brentozar.com/archive/2011/07/how-set-up-sql-server-denal...
Service Accounts
In the Database Engine Con guration step, make sure to click Add Current User as an administrator for the
database engine. Also in this step, click on the Data Directories tab and con gure the default le paths. Use the
same paths across all of the SQL Server instances were using for AlwaysOn.
Installation Paths
Next your way through the installation, and a few minutes later, youll have yourself one working SQL Server.
Repeat that process for all of your 2012 machines.
Con guration Manager. Drill into SQL Server Network Con guration, click on Protocols for MSSQLSERVER, and
double-click on the TCP/IP entry. Change the Enabled option to Yes, and click OK.
Back in Con guration Manager, enable AlwaysOn by clicking SQL Server Services in the left pane, then
double-click SQL Server. Click on the AlwaysOn High Availability tab. (Wait if its AlwaysOn, shouldnt it be
called Complete Availability? Hmmm.)
Click OK. Our changes wont take e ect until we restart the SQL Server instance, so nows a good time to do
that. Repeat this process for all of your 2012 instances.
Open SQL Server Management Studio and connect to one of the instances. Go into Security, right-click on
Logins, and create a new login. Click Search, and put in one of the service account names that you used for
each SQL Server. On the left side, click Server Roles, check the sysadmin box, and click OK.
10 of 15 10/21/2016 8:38 PM
How to Set Up SQL Server Denali Availability Groups https://www.brentozar.com/archive/2011/07/how-set-up-sql-server-denal...
each SQL Server. On the left side, click Server Roles, check the sysadmin box, and click OK.
Repeat this process for every service account, and repeat it on every instance. In all, youre going to be setting
up 3 accounts per server on all 4 servers.
A slightly easier way (and my personal favorite): put the service accounts in an Active Directory group instead,
and then create a login for the group. If you take that approach, be aware that groups dont show up by
default when youre searching in the new-login creation process. After you click Search, click Object Types, and
check Groups.
Last, but not least, we need a le share that all four service accounts can access. Were going to initialize our
replicas with backups and restores, and to do that, all four services need to be able to read & write to the same
folder. This le share can be on any le server or on one of the SQL Servers, but make sure to grant rights to
read/write for all of the service accounts. (Again, made easier if were using AD groups.)
If you were doing database mirroring before, then youve probably already dealt with le share permissions
and Active Directory. AlwaysOn Availability Groups dont change anything there. However, they do add the
requirement for a virtual network name and IP address. Thats not a big requirement.
In SSMS, go into the main production server, click Management, right-click on Availability Groups, and click
New Availability Group Wizard. Youll be presented with a list of databases that you can include in the
Availability Group. Keep in mind that all of the databases in the Availability Group will be failed over from your
primary server to your secondary server together, automatically. In my case, my accounting application
consists of the databases Accounting, AccountingPayroll, and AccountingReports. I have some applications
11 of 15 10/21/2016 8:38 PM
How to Set Up SQL Server Denali Availability Groups https://www.brentozar.com/archive/2011/07/how-set-up-sql-server-denal...
primary server to your secondary server together, automatically. In my case, my accounting application
consists of the databases Accounting, AccountingPayroll, and AccountingReports. I have some applications
that make cross-database SELECT queries for reporting purposes, so I want to make sure they all fail over
together.
Click Next, and youll be able to specify which servers are part of the group and what their roles are. This below
screen has so much of what Ive always wanted in a database product. Ill need just a moment by myself.
Excuse me.
12 of 15 10/21/2016 8:38 PM
How to Set Up SQL Server Denali Availability Groups https://www.brentozar.com/archive/2011/07/how-set-up-sql-server-denal...
This is, as Martha Stewart would say, a Good Thing. Lets take it one column at a time:
Initial Role SQL2012PROD1 will be my Primary instance because its got the current live copy of the data.
Replica Mode PROD1 and PROD2 will do Automatic Failover. Only two instances can be involved in Automatic
Failover at a time. For my business con guration, DR1 and RPT1 are in High Performance mode, which is akin
to asynchronous database mirroring. High Safety is also an option, meaning synchronous mirroring.
Connection Mode in Secondary Role when this instance isnt the primary instance, will it allow connections?
If so, then we have to be aware that its performance will slow down. Im not keen on allowing any connections
to my server thats acting as an automatic failover partner, because that server needs to commit writes as fast
as possible. In my setup, Ive got PROD1 and PROD2 set to disallow connections for that reason. My DR1 and
RPT1 instances, however, can allow connections, thereby letting my read-only users connect there to run
reports or backups.
Thats amazing. This is probably the coolest screen of any wizard Ive ever seen. This one screen lets me
protect and scale out multiple databases easily. Granted, it took us 2,800 words of explanation to get to this
point, but its way easier than any other scale-out method Ive seen. Its all in the GUI, for crying out loud.
Click Next, and the next screen will set up a listener. You can just take the defaults here.
On the Select Initial Data Synchronization screen, put in the UNC path for the le share that you set up for all of
the SQL Servers to access. The production server is going to take a backup to this path, and the replicas will
restore that backup. You can also skip this step entirely if youd rather initialize the replicas yourself, and in
many production environments, youll need to do that. For example, environments with SAN snapshot
capabilities or small WAN pipes will need customization.
Next your way through the wizard and validation, and next thing you know, youve got an Availability Group.
Right-click on your new Availability Group and click Show Dashboard. Presto:
13 of 15 10/21/2016 8:38 PM
How to Set Up SQL Server Denali Availability Groups https://www.brentozar.com/archive/2011/07/how-set-up-sql-server-denal...
Take your full and transaction log backups on a replica. (You cant do di erential backups on the replicas
long story.)
Automatic page repair 2012 automatically detects corrupt pages on the replicas and repairs them by
fetching a good copy from any other instance
Replication Availability Groups can include a replication publisher, but not the distributor
Im really, really excited about AlwaysOn Availability Groups. Yes, it requires some compromises (like Windows
Enterprise and an additional name/IP) but its worth it.
15 of 15 10/21/2016 8:38 PM