015 - SQL - Server - 2012 - Features - For - Admins - Lesson 15 - SQL - 2012 - AlwaysOn - Lab - Manual

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Lesson 15 : SQL 2012 AlwaysOn Availability Groups 1

Lesson 15: SQL Server


AlwaysOn Availability Groups

Microsoft | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential
2 Lesson 15 : SQL 2012 AlwaysOn Availability Groups

Conditions and Terms of Use


Microsoft Confidential - For Internal Use Only

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.

© 2012 Microsoft Corporation. All rights reserved.

Copyright and Trademarks


© 2012 Microsoft Corporation. All rights reserved.

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 3

SQL Server 2012 AlwaysOn Availability Groups

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

Estimated time to complete this lab


60 minutes

Virtual Machines Needed for this Lab:


 SQL11AdminWork
 SQLAdmin11CN1
 SQLAdmin11CN2
 SQLAdmin11CN3

For more information


Overview of AlwaysOn Availability Groups (SQL Server)
http://msdn.microsoft.com/en-us/library/ff877884.aspx

Microsoft | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential
4 Lesson 15 : SQL 2012 AlwaysOn Availability Groups

Exercise 1: Connect to an existing AlwaysOn


Availability Group

Objectives
In this exercise, you will:
 Connect to and inspect an existing AlwaysOn Availability Group

1. Login into SQL11AdminWork if you are not already.

Note: If prompted, use the following credentials when connecting to the virtual
machine:
User: SQLADMIN11\Administrator
Password: sqladmin11

2. Launch SQL Management Studio


3. When the “Connect to Server” dialog box opens, connect to SQL11AdminCN1
4. Expand the AlwaysOn High Availability > Availability Groups > adventscore
a. Expand and inspect the contents of these sub groups. Contents should appear
like the screenshot below.

5. Below is an explanation of the items under the Availability Group folder


a. Availability Group – This system is configured with a single availability group
named adventscore

Microsoft | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 5

i. The adventscore group is setup across three Availability Replicas –


SQLADMIN11CN1, SQLADMIN11CN2, and SQLADMIN11CN3
ii. There are two Availability Databases that are members of this group,
Adventurteworks2012 and Adventureworks2012DW. If a failure was to
occur, the availability group is designed to failover both databases
simultaneously to another replica.
iii. Availability Group Listeners – This availability group has a single
listener named adventscore. A listener is a virtual network name that
clients connect to so they are not dependent on a specific server or
replica being online.

Exercise 2: Create a new AlwaysOn Availability


Group

Objectives
In this exercise, you will:
 Create AlwaysOn Availability Group

1. Login into SQL11AdminWork if you are not already.

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential
8 Lesson 15 : SQL 2012 AlwaysOn Availability Groups

g. At the Specify Availability Group Name screen, enter NewDB2012AG as the


name of your group and click Next

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 9

i. At the Specify Replicas screen, click Add Replica, enter SQLADMIN11CN2,


and click Connect. Repeat this for SQLAdmin11CN3
i. SQLAdmin11CN1-Make sure Synchronous Commit is selected
ii. SQLAdmin11CN2 - select AutoFailover and Synchronous Commit
iii. SQLAdmin11CN3 – leave boxes unchecked for Asynchronous and
Manual Failover

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential
10 Lesson 15 : SQL 2012 AlwaysOn Availability Groups

c. Do not add an ip address for the 192.168.0.0 network

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

m. Click Next and Finish to create the Availability Group

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential
12 Lesson 15 : SQL 2012 AlwaysOn Availability Groups

Exercise 3: Monitor a SQL Server Availability Group

Objectives
In this exercise, you will:
 Monitor an AlwaysOn Availability Group using the Availability Group Dashboard
 Initiate a manual failover

1. Login into SQL11AdminWork if you are not already.

Note: If prompted, use the following credentials when connecting to the virtual
machine:
User: SQLADMIN11\Administrator
Password: sqladmin11

2. Launch SQL Management Studio


3. When the Connect to Server dialog box opens, connect to SQL11AdminCN1
4. Expand the AlwaysOn High Availability > Availability Groups > NewDB2012AG
(primary) > Show Dashboard
5. Note: If the step above shows “(secondary)” instead of “(primary)”, connect to
SQL11AdminCN2 instead. The dashboard can be launched from either replica, but
more detailed information will be displayed when it is launched from the primary.
6. The dashboard should look similar to the screenshot below. Green icons indicate a
good health state for the databases in the availability group. If there was a problem
with any of the databases that could prevent a successful failover, this screen would
show yellow or red icons along with information related to the problem.

Microsoft | Services © 2012 Microsoft Corporation ITOE Educate Workshop

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

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)

11. Return to the dashboard screen. SQLADMIN11CN1 and SQLADMIN11CN2 should


have swapped primary/secondary roles. If they have not, close and re-launch the
dashboard in order to refresh.

Microsoft | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 15

Exercise 4: Connect to the listener and simulate an


unexpected failure.

Objectives
In this exercise, you will:
 Connect a sample application to the listener.
 Simulate an unexpected failure.

1. Login into SQL11AdminWork if you are not already.


2. Launch Management Studio and connect with the following connection settings.
Note: Because the servers in this lab are on multiple subnets, the
MultiSubnetFailover connection parameter is required. This is set in the advanced
screen.
a. Enter Server Name – NewDB2012-LIST and then click Options

Microsoft | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential
16 Lesson 15 : SQL 2012 AlwaysOn Availability Groups

b. On the Additional Connection Parameters tab > enter


MultiSubnetFailover=True

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential
Lesson 15 : SQL 2012 AlwaysOn Availability Groups 17

7. Now connect to whatever server the listener is resolving to in Management Studio.


Position the cmd window and management studio so you can see both windows.
Right click the server > Stop. Click ok to also stop SQL Server Agent.

8. Watch the command window. After a short period, the connection should timeout
and then fail over to the other replica.

Microsoft | Services © 2012 Microsoft Corporation ITOE Educate Workshop

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

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 | Services © 2012 Microsoft Corporation ITOE Educate Workshop

Microsoft Confidential

You might also like