Sunteți pe pagina 1din 39

Exploring

AlwaysOn
Availability
Groups

Contents
Windows Failover Cluster (WSFC) ................................. 3
AlwaysOn Availability Groups......................................... 3
Availability Group Listener ............................................ 14
Active Secondaries On Prem .....................................17
High Availability for unstructured data .......................19
Test AlwaysOn is working (simulate a failover) ........ 35
Terms of use ..................................................................... 38

Exploring AlwaysOn Availability Groups

Windows
Failover
Cluster
(WSFC)

Estimated time to complete lab is 30 minutes


The availability of data is an important issue for many organizations, as
a database being unavailable would significantly affect their ability to
service customers or their ability to carry out day-to-day processes. The
Always On features in SQL Server 2014 are designed to ensure the
database is still available, even when the primary server goes down.
High availability through AlwaysOn requires the member server
operating systems be set up as a Windows Failover Cluster (WSFC). The
Failover Cluster is comprised of a primary server and one or more
secondary servers that, depending on their configuration, provide
automated failover protection and other critical database services
Multi sub-net failover clustering is possible, where some or all nodes
are connected to a different subnet or different set of subnets. These
subnets can be in the same location or in geographically dispersed
sites, forming a geo-cluster, sometimes known as a stretch cluster

AlwaysOn
Availability
Groups

The AlwaysOn failover feature works on grouping of one or more user


databases, known as Availability Groups. In SQL 2014 the number of
secondaries has been increased from four to eight and it now allows
Failover Cluster Instance (FCI) customers to configure CSV paths for
system and user databases.
Connect to SQLONE computer
1. Click on SQLONE button on right side of the screen to connect
to the SQLONE computer. If you see the following in the lower
right corner of the screen, you can jump to step 5 below to set
your screen resolution.

2. Click Send Ctrl-Alt-Del for SQLONE computer and then click


Switch user.
3. Click Send Ctrl-Alt-Del for SQLONE computer again and then
click Other user.
Exploring AlwaysOn Availability Groups

4. Log on to SQLONE computer as labuser with password


pass@word1
Note, if you have a monitor that supports a larger screen resolution than
1024 x 768, you can change the screen resolution for the lab to go as
high as 1920 x 1080. By going to a higher screen resolution, it will be
easier to use SQL Server Management Studio.
5. Right click on the desktop and click on Screen resolution.
6. Select 1366 x 786 (a good minimum screen size for using
SSMS) and click OK.
7. Click Keep Changes.
8. Resize the client holLaunchPad Online window for the lab to
fit your screen resolution.
Enable AlwaysOn
1. Open SQL Server 2014 Configuration Manager from the
Windows start screen (click the down arrow in the bottom-left
corner of the start screen to see the more apps section, then
browse until you find the program, or enter the first few letters
of the program name and click on the program from the list of
options this creates)
2. Click Yes in the User Account Control dialog box
3. Select SQL Server Services and then right-click on SQL Server
(MSSQLSERVER) and select Properties

4. Select the tab AlwaysOn High Availability

Exploring AlwaysOn Availability Groups

5. Select Enable AlwaysOn Availability Groups and then click


OK

The SQL Server service requires a restart for the above changes to take
effect
6. Click OK
7. Right-click on SQL Server (MSSQLSERVER) and select Restart

Exploring AlwaysOn Availability Groups

8. Click on SQLTWO on the lab navigation pane and perform


steps 1 through 7 above to enable AlwaysOn Availability Groups
for the server.
9. Click on SQLTHREE on the lab navigation pane and perform
steps 1 through 7 above to enable AlwaysOn Availability Groups
for the server.
10. Click on SQLONE to return back to the SQLONE server.
Create your Availability Groups
1. Open SQL Server 2014 Management Studio from the
Windows Start screen, which automatically opens a connection
dialog

Exploring AlwaysOn Availability Groups

2. Enter Database Engine as the type, SQLONE as the server


name, ensure Windows Authentication is selected, and then
click Connect
3. Expand AlwaysOn High Availability in the Object Explorer
under the connected database (SQLONE), and then right-click
on Availability Groups and select New Availability Group
Wizard

4. Click Next for the Introduction page.


5. In Availability group name enter AG1

Exploring AlwaysOn Availability Groups

6. Click Next
7. Check the database ContosoRetailDW and then click Next

Add two secondary replicas.


Exploring AlwaysOn Availability Groups

Note: In SQL Server 2014 the number of secondary replicas allowed has
been increased to eight
1.

Click on Add Replica and then in Server name enter


SQLTWO and then click Connect

2. Click on Add Replica and then in Server name enter


SQLTHREE and then click on Connect
3. Check the box Automatic Failover (Up to 2) for SQLONE and
SQLTWO

Exploring AlwaysOn Availability Groups

Notice how Synchronous Commit (Up to 3) is automatically selected,


Synchronous Commit is required for Automatic Failover
4. Click Next
5. Select Full and in the box Specify a shared network location
accessible by all replicas enter \\SQLONE\SQLBACKUPS

Exploring AlwaysOn Availability Groups

10

6. Click Next
7. Review the results of the availability group validation and then
click Next
Note: Ignore the warning about Listener configuration as we will add a
Listener below.

Exploring AlwaysOn Availability Groups

11

8. Verify the choices and then click Finish

9. Review the Results and then click Close


Exploring AlwaysOn Availability Groups

12

NOTE: will take approx. 5 mins

Confirm Availability Group


1. In the SQL Server 2014 Management Studio, in Object
Explorer, click on Connect and then Database Engine
2. In Server name enter SQLTWO and then click Connect

3. Expand Databases

Exploring AlwaysOn Availability Groups

13

The databases ContosoRetailDW will have been restored to SQLTWO


and will have a status of either (Restoring) or (Synchronizing)
depending on whether the restoration has completed

Availability
Group
Listener

An Availability Group Listener is a virtual network name to which


clients can use to connect to a database in a primary or secondary
replica of an Availability Group. The listener enables a client to connect
to an availability replica without knowing the name of the physical
instance of SQL Server. Now, client applications can achieve failover
across multiple subnets (as many as 64) almost as fast as they can
achieve failover within a single subnet
Enable Availability Group to use an Availability Group Listener
1. Expand the AlwaysOn High Availability node in the Object
Explorer for SQLONE, then Availability Group and then AG1
(Primary)

Exploring AlwaysOn Availability Groups

14

2. Right-click on the Availability Group Listeners node and


select Add Listener
3. In Listener DNS Name enter AG1Listener
4. Under Port enter 1444
5. Under Network Mode select Static IP

Exploring AlwaysOn Availability Groups

15

6. Click Add and then in IPv4 Address enter 192.168.1.213

7. Click OK
8. Click OK

Exploring AlwaysOn Availability Groups

16

Active
Secondaries
On Prem

SQL Server AlwaysOn Multiple, Active Secondaries enables use of as


many as eight secondary instances for running report queries (many
times faster than replication) and backup operations, even in the
presence of network failureswhich helps in repurposing idle
hardware and improving resource utility. It also helps to dramatically
improve performance for both primary and secondary workloads
because they are no longer competing for resources. Active Readable
Secondaries help maximize return on server investment when they are
enabled for read-only applications
Enable secondarys to be readable
1.

Expand AlwaysOn High Availability in the Object Explorer


for SQLONE and then Availability Group

2. Right-click on the availability replica AG1 (Primary) and select


Properties

Exploring AlwaysOn Availability Groups

17

In this view we can see the detailed configuration of our Availability


Group. We notice the primary server is SQLONE, and the two secondary
servers are SQLTWO and SQLTHREE. We arent limited to just two
secondary servers like we have here, as many as eight secondarys can
be created.
3. In the Availability Replicas section, click the drop-down next
to Readable Secondary for SQLTWO and change the value to
Yes

Exploring AlwaysOn Availability Groups

18

4. In the Availability Replicas section, click the drop-down next


to Readable Secondary for SQLTHREE and change the value
to Yes
5. Click OK
SQLTWO and SQLTHREE are now configured to be readable secondary
replicas

High
Availability
for
unstructured
data

With SQL Server, complex data types are handled with the same
attention as common data types. Organizations can use FILESTREAM to
store and manage complex data in a variety of ways, as if it were part of
the database. Additionally, with SQL Server, organizations can enjoy
the high-availability benefits of AlwaysOn for complex data managed
through FILESTREAM even when they take advantage of Remote Blog
Storage and FileTable
In this scenario, you will use FILESTREAM to store and manage complex
data, as if it were part of the database and include this complex data in
the AlwaysOn configuration you previously set up.
Enabling FILESTREAM across the Availability Group.
1. Open SQL Server 2014 Configuration Manager, if not open
already, by opening the Windows Start screen, typing a few
letters of the program name (eg conf) and clicking on the
program name in the list of options this produces. If the desired
Exploring AlwaysOn Availability Groups

19

program is not listed, type a longer portion of its name and try
again)

2. Select SQL Server Services

3. If a User Account Control dialog box appears, click Yes


4. Right-click on SQL Server (MSSQLSERVER) and select
Properties

5. In the SQL Server Properties dialog box, click the


FILESTREAM tab
6. Select Enable FILESTREAM for Transact-SQL access and then
Enable FILESTREAM for the I/O access check boxes
Exploring AlwaysOn Availability Groups

20

7. Click OK
8. If SQL Server 2014 Management Studio is already open,
ensure you have a connection to the SQLONE server listed in
the Object Explorer. If you do not, click the Connect button at
the top of the Object Explorer and select Database Engine
then enter the details as for the next step of this click-through.
9. If SQL Server 2014 Management Studio is not already open,
open it from the Windows Start screen and enter the following
details. Server Type: Database Engine Server Name: SQLONE
Authentication Type: Windows Authentication. Click Connect

Exploring AlwaysOn Availability Groups

21

10. Open the File menu, click Open and then File

11. Browse to C:\SQLSCRIPTS\E2 and select E2A-9-#1

Exploring AlwaysOn Availability Groups

22

12. Click Open

13. Click Execute


14. Return to SQL Server Configuration Manager
15. Select SQL Server Services and then Right-click on SQL Server
(MSSQLSERVER) and then select Restart

Exploring AlwaysOn Availability Groups

23

NOTE: this restart causes the server to automatically failover, as


SQLONE is stopped before starting again.
16. You can verify that failover by switching to SQL Server
Management Studio and refreshing the Availability Groups
node for SQLONE.

17. Close the SQL Server Configuration Manager.


Create a new FILESTREAM-enabled database
For FILESTREAM to be supported across the Availability Group, all SQL
Servers in the Availability Group must have FILESTREAM configured, as
you have done for SQLONE. This has been done for you for SQLTWO
and SQLTHREE.
Now that you have enabled FILESTREAM, lets use FILESTREAM with the
database called ContosoImages. The following script will create a new
FILESTREAM-enabled database called ContosoImages and will add the
following image file to the database

Exploring AlwaysOn Availability Groups

24

1.

On SQLONE in SQL Server 2014 Management Studio, open


the File menu, click Open then File

2. Browse to C:\SQLSCRIPTS\E2 and select E2A-9-#2


3. Click Open

4. Click Execute above the query window


Now you he created a FILESTREAM-enabled database and can add it to
you AlwaysOn Availability group. Before you can add the database to
the Availability Group, a full Backup of the ContosoImages database is
required
Backup the ContosoImages database
1. Open File Explorer and navigate to the C:\SQLBACKUPS
directory. Delete the two existing backup files:
ContosoImages.bak
ContosoImages_2014052701272.trn

Exploring AlwaysOn Availability Groups

25

2. Switch back to Management Studio and expand Databases in


the Object Explorer and then right-click on ContosoImages
and select Tasks and then Back Up

3. Ensure Backup type is Full

Exploring AlwaysOn Availability Groups

26

The backup destination drive is set to C:\SQLBACKUPS which is also


\\SQLONE\SQLBACKUPS which is the shared drive on the network that
SQLTWO and SQLTHREE can access.
4. Click OK twice

You need to failover the availability group back to SQLONE before you
can add databases from SQLONE to it (the group was failed over to
SQLTWO when we restarted the server after enabling FILESTREAM.)
5. Expand AlwaysOn High Availability in the Object Explorer
and then Availability Groups
Exploring AlwaysOn Availability Groups

27

6. Right-click on AG1 (Secondary) and select Failover

7. Click Next for the Introduction page.

Exploring AlwaysOn Availability Groups

28

8. Click Next for the Select New Primary Replica page. SQLONE
is selected as the new primary replica.

9. Finish for the Summary page.

10. Click Close for the completion page.


11. In the Object Explorer, expand AlwaysOn High Availability
> Availability Groups nodes, then expand AG1 (Primary)

Exploring AlwaysOn Availability Groups

29

12. Right-click on Availability Databases and select Add


Database
13. Click Next
14. Select ContosoImages and then click Next

Exploring AlwaysOn Availability Groups

30

15. Ensure data synchronization preference is set to Full and the


shared network location accessible to all replicas is
\\SQLONE\SQLBACKUPS
16. Click Next

Exploring AlwaysOn Availability Groups

31

17. Click on the Connect button next to SQLTWO


18. Click Connect
19. Click on the Connect button next to SQLTHREE
20. Click Connect

Exploring AlwaysOn Availability Groups

32

21. Click Next


22. Verify the Validation and then click Next

Exploring AlwaysOn Availability Groups

33

23. Click Finish

Exploring AlwaysOn Availability Groups

34

24. Click Close


25. Exit Microsoft SQL Management Studio without saving.
You have now configured FILESTREAM to store and manage complex
data as if it were part of the database and included this complex data in
the AlwaysOn configuration you previously set up.

Test
AlwaysOn is
working
(simulate a
failover)

Create a data connection


1. Log in to the SQLTHREE virtual machine as Contoso\labuser
with the password pass@word1. Click Send-Ctl-Alt-Del to get
to the sign in page.
2. Open SQL Server 2014 Management Studio by clicking the
icon in the taskbar at the bottom of the screen
3. Enter AG1Listener as the server name, Windows
Authentication as the Authentication and click Connect

Exploring AlwaysOn Availability Groups

35

4. Click New Query and enter the following query:


Select * from ContosoRetailDW.dbo.DimProductCategory

Click on Execute (this will return 8 rows. Leave the query


window open.)

Test AlwaysOn
1. Ensure you are also logged into the SQLONE virtual machine as
Contoso\labuser with the password pass@word1 (note, do
not close the SQLTHREE window, you will be using it shortly.)
2. From SQLONE open SQL Server 2014 Configuration
Manager
3. Select SQL Server Services
4. Right-click on SQL Server (MSSQLSERVER) and select Stop
Exploring AlwaysOn Availability Groups

36

SQLONE server is now down and unavailable


5. Open on SQLTHREE the SQL Management Studio with the
previously typed in query open, click Execute again

Notice how the data refreshed and is still available although SQLONE is
down the original source of the data.
6. Close everything on SQLTHREE without saving then log out of
SQLTHREE.
This lab is complete

Exploring AlwaysOn Availability Groups

37

Terms of
use

2014 Microsoft Corporation. All rights reserved.

By using this Hands-on Lab, you agree to the following terms:


The technology/functionality described in this Hands-on Lab is
provided by Microsoft Corporation in a sandbox testing environment
for purposes of obtaining your feedback and to provide you with a
learning experience. You may only use the Hands-on Lab to evaluate
such technology features and functionality and provide feedback to
Microsoft. You may not use it for any other purpose. You may not
modify, copy, distribute, transmit, display, perform, reproduce, publish,
license, create derivative works from, transfer, or sell this Hands-on Lab
or any portion thereof.
COPYING OR REPRODUCTION OF THE HANDS-ON LAB (OR ANY
PORTION OF IT) TO ANY OTHER SERVER OR LOCATION FOR FURTHER
REPRODUCTION OR REDISTRIBUTION IS EXPRESSLY PROHIBITED.
THIS HANDS-ONLAB PROVIDES CERTAIN SOFTWARE
TECHNOLOGY/PRODUCT FEATURES AND FUNCTIONALITY,
INCLUDING POTENTIAL NEW FEATURES AND CONCEPTS, IN A
SIMULATED ENVIRONMENT WITHOUT COMPLEX SET-UP OR
INSTALLATION FOR THE PURPOSE DESCRIBED ABOVE. THE
TECHNOLOGY/CONCEPTS REPRESENTED IN THIS HANDS-ON LAB
MAY NOT REPRESENT FULL FEATURE FUNCTIONALITY AND MAY NOT
WORK THE WAY A FINAL VERSION MAY WORK. WE ALSO MAY NOT
RELEASE A FINAL VERSION OF SUCH FEATURES OR CONCEPTS. YOUR
EXPERIENCE WITH USING SUCH FEATURES AND FUNCITONALITY IN A
PHYSICAL ENVIRONMENT MAY ALSO BE DIFFERENT.
FEEDBACK. If you give feedback about the technology features,
functionality and/or concepts described in this Hands-on Lab to
Microsoft, you give to Microsoft, without charge, the right to use, share
and commercialize your feedback in any way and for any purpose. You
also give to third parties, without charge, any patent rights needed for
their products, technologies and services to use or interface with any
specific parts of a Microsoft software or service that includes the
feedback. You will not give feedback that is subject to a license that
requires Microsoft to license its software or documentation to third
parties because we include your feedback in them. These rights survive
this agreement.
MICROSOFT CORPORATION HEREBY DISCLAIMS ALL WARRANTIES
AND CONDITIONS WITH REGARD TO THE HANDS-ON LAB ,
INCLUDING ALL WARRANTIES AND CONDITIONS OF
MERCHANTABILITY, WHETHER EXPRESS, IMPLIED OR STATUTORY,
Exploring AlwaysOn Availability Groups

38

FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. MICROSOFT DOES NOT MAKE ANY ASSURANCES OR
REPRESENTATIONS WITH REGARD TO THE ACCURACY OF THE
RESULTS, OUTPUT THAT DERIVES FROM USE OF THE VIRTUAL LAB, OR
SUITABILITY OF THE INFORMATION CONTAINED IN THE VIRTUAL LAB
FOR ANY PURPOSE.
DISCLAIMER
This lab contains only a portion of new features and enhancements in
Microsoft SQL Server 2014. Some of the features might change in
future releases of the product. In this lab, you will learn about some,
but not all, new features.

Exploring AlwaysOn Availability Groups

39

S-ar putea să vă placă și