Professional Documents
Culture Documents
015 - SQL - Server - 2012 - Features - For - Admins - Lesson 15 - SQL - 2012 - AlwaysOn - Lab - Manual
015 - SQL - Server - 2012 - Features - For - Admins - Lesson 15 - SQL - 2012 - AlwaysOn - Lab - Manual
015 - SQL - Server - 2012 - Features - For - Admins - Lesson 15 - SQL - 2012 - AlwaysOn - Lab - Manual
Microsoft Confidential
2 Lesson 15 : SQL 2012 AlwaysOn Availability Groups
This training package is proprietary and confidential, and is intended only for uses described in the training
materials. Content and software is provided to you under a Non-Disclosure Agreement and cannot be
distributed. Copying or disclosing all or any portion of the content and/or software included in such packages is
strictly prohibited.
The contents of this package are for informational and training purposes only and are provided "as is" without
warranty of any kind, whether express or implied, including but not limited to the implied warranties of
merchantability, fitness for a particular purpose, and non-infringement.
Training package content, including URLs and other Internet Web site references, is subject to change without
notice. Because Microsoft must respond to changing market conditions, the content should not be interpreted to
be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information
presented after the date of publication. Unless otherwise noted, the companies, organizations, products,
domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no
association with any real company, organization, product, domain name, e-mail address, logo, person, place, or
event is intended or should be inferred.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights
covering subject matter in this document. Except as expressly provided in written license agreement from
Microsoft, the furnishing of this document does not give you any license to these patents, trademarks,
copyrights, or other intellectual property.
Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under
copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or
transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for
any purpose, without the express written permission of Microsoft Corporation.
For more information, see Use of Microsoft Copyrighted Content at
http://www.microsoft.com/about/legal/permissions/
Microsoft®, Internet Explorer®, and Windows® are either registered trademarks or trademarks of Microsoft
Corporation in the United States and/or other countries. Other Microsoft products mentioned herein may be
either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.
All other trademarks are property of their respective owners.
Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 3
Introduction
In this lab you will learn how to connect to, create, monitor, and failover an AlwaysOn
Availability Group
Objectives
After completing this lab, you will be able to:
Connect to an Availability Group
Create an Availability Group
Perform a failover
Monitor an Availability Group
Microsoft Confidential
4 Lesson 15 : SQL 2012 AlwaysOn Availability Groups
Objectives
In this exercise, you will:
Connect to and inspect an existing AlwaysOn Availability Group
Note: If prompted, use the following credentials when connecting to the virtual
machine:
User: SQLADMIN11\Administrator
Password: sqladmin11
Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 5
Objectives
In this exercise, you will:
Create AlwaysOn Availability Group
Note: If prompted, use the following credentials when connecting to the virtual
machine:
User: SQLADMIN11\Administrator
Password: sqladmin11
2. Note: SQLAdminCN1 was created with a default database folder on a remote share.
For the purpose of this exercise, we want to create all databases on the C: drive in the
Data folder. We need to create this folder on SQL11AdminCN1
a. From SQLAdminWork, open file explorer and navigate to
\\SQLAdmin11CN1\c$
b. Drill down to this path - \Program Files\Microsoft SQL
Server\MSSQL11.MSSQLSERVER\MSSQL
c. Right click > New Folder > Name the new folder “DATA”
Microsoft Confidential
6 Lesson 15 : SQL 2012 AlwaysOn Availability Groups
d. Right click DATA folder > Properties > Security Tab > Edit > Add > type in
“sqlsvc” > Check Name > Ok > Select “full control”
3. Now let’s create a new database that we can protect with a new Availability Group.
a. Connect to SQLAdmin11CN1 with Management Studio
b. Right click databases > New database > Name the new database NewDB2012.
Be sure select C:\Program Files\Microsoft SQL
Server\MSSQL11.MSSQLSERVER\MSSQL\DATA as the folder for the log
and data files before creating the database.
Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 7
c. Under the options tab, make sure the database recovery mode of Full is set. A
database cannot be added to an availability group unless it is in Full mode
d. Create an initial full backup of NewDB2012
i. Right click NewDB2012 > Backup
ii. You can accept the default location for the backup > ok
e. Create a new availability group – Navigate to AlwaysOn High Availability >
Availability Groups > Right Click > New Availability Group Wizard
f. New Availability Group wizard should launch. Click next at the initial splash
screen.
Microsoft Confidential
8 Lesson 15 : SQL 2012 AlwaysOn Availability Groups
h. Select NewDB2012 as the database we want to add to this new group and click
Next. Note: The status should show “Meets Prerequisites”. If the database
does not meet prerequisites, make sure the database is in Full mode and that a full
backup was run.
Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 9
j. Click the listener tab and select Create and Availability Group Listener. In this
example, we are going to configure the listener for SQLAdmin11CN1 and
SQLAdmin11CN2, but not SQLAdmin11CN3.
i. Listener DNS Name – NewDB2012-List (note – Be sure to use this
exact name for your listener as we will be referencing it later)
ii. Port – 1433
iii. Network Mode – Static IP
1. Click Add to add an IPs address.
a. 9.0.0.0/8 subnet > enter 9.3.1.6
b. 10.0.0.0/8 subnet > enter 10.3.1.6
Microsoft Confidential
10 Lesson 15 : SQL 2012 AlwaysOn Availability Groups
k. On the select initial data synchronization screen, accept the default of Full
backup and the backup share location of \\SQLADMIN11DC\SQLBackups.
Click Next
l. The validation screen should verify all settings are correct and report all green. If
there are no errors, click next
n. When the availability group has been created, you should see a screen like this.
(Note: The yellow WSFC warning is bogus can be ignored in this situation. This
Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 11
warning has been fixed in SQL2012 SP1, but at the time of this writing, the
virtual environment has not been updated with SP1.
http://support.microsoft.com/kb/2833122)
Microsoft Confidential
12 Lesson 15 : SQL 2012 AlwaysOn Availability Groups
Objectives
In this exercise, you will:
Monitor an AlwaysOn Availability Group using the Availability Group Dashboard
Initiate a manual failover
Note: If prompted, use the following credentials when connecting to the virtual
machine:
User: SQLADMIN11\Administrator
Password: sqladmin11
Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 13
7. Click “Start Failover Wizard” in the upper right hand corner of the dashboard. This
can be used to initiate a planned/manual failover of an availability group to another
replica.
8. At the Select New Primary Replica screen, select SQLADMIN11CN1 as the replica
you want to failover to and select Next. (Select SQLADMIN11CN2 if you are failing
over in the other direction)
Microsoft Confidential
14 Lesson 15 : SQL 2012 AlwaysOn Availability Groups
9. Management Studio now needs to connect to the destination replica in order to start
the failover. Click Connect > Connect > Next
10. When the failover is complete, you should see a screen like this. (Note: The yellow
WSFC warning is bogus can be ignored in this situation. This warning has been
fixed in SQL2012 SP1, but at the time of this writing, the virtual environment has not
been updated with SP1. http://support.microsoft.com/kb/2833122)
Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 15
Objectives
In this exercise, you will:
Connect a sample application to the listener.
Simulate an unexpected failure.
Microsoft Confidential
16 Lesson 15 : SQL 2012 AlwaysOn Availability Groups
3. Now let’s check which server the listener connected this session to. In object
explorer > Right click NewDB2012-LIST > New Query
4. In the new query window that opens, enter the following query and execute by
pressing F5 or the ! button
SELECT @@servername
5. Note the server name that is returned, (either SQLADMIN11CN1 or
SQLADMIN11CN2). By using a virtual listener name, you are able to ensure an
Availability Group SQL replica is available to respond to application requests in a
situation where the other replica is down for maintenance or an unexpected failure.
6. On SQLAdminWORK, navigate to L:\Features\Labs\Lesson 15 – AlwaysOn, find
ConnectApp.cmd, and double click to run. This script will connect to the listener
and loop every 5 seconds running a query to return the current server name. Check
the console output to see what server the listener is sending the script to.
Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 17
8. Watch the command window. After a short period, the connection should timeout
and then fail over to the other replica.
Microsoft Confidential
18 Lesson 15 : SQL 2012 AlwaysOn Availability Groups
9. Connect to the new primary replica and launch dashboard to check health status.
You should see the node you stopped listed in red.
Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 19
10. Right click the node you stopped in Object Explorer > Start. Observe the dashboard
and wait until status returns to green.
Microsoft Confidential