Using SQL Server 2012's Always On (HADR)

Post on 22-Feb-2016

30 views 3 download

Tags:

description

Using SQL Server 2012's Always On (HADR). Denny Cherry mrdenny@mrdenny.com twitter.com/ mrdenny. About Me. Independent Consultant Founder of SQL Excursions Author or Coauthor of 5 books 8 + SQL Mag articles Dozens of other articles Microsoft MVP Microsoft Certified Master. - PowerPoint PPT Presentation

Transcript of Using SQL Server 2012's Always On (HADR)

Using SQL Server 2012's Always On (HADR)

Denny Cherrymrdenny@mrdenny.com

twitter.com/mrdenny

2

About MeIndependent ConsultantFounder of SQL ExcursionsAuthor or Coauthor of 5 books8+ SQL Mag articlesDozens of other articlesMicrosoft MVPMicrosoft Certified Master

What is “Always On”?AKA “HADR”Combines Best of Mirroring and ClusteringCan allow for backups to be read

What Parts of Clustering?Uses the clustering APIs for failoverNo shared storage, users still connect to

normal instanceShared IP Address for Availability Group

Listener

What Parts of Mirroring?Uses Mirroring Concepts for the data

transportUses Mirroring TCP Endpoint

New Terms to KnowAvailability GroupsAvailability ReplicasAvailability Databases

Setup RequirementsAll Instances must be installed on Windows

2008 R2 Enterprise (or higher)All servers running as part of HADR much be

in a single Windows clusterSQL is not clusteredDatabases must be in full recovery

Setup NotesMultiple Databases in a single Availability

GroupIO profiles on primary and secondary are

differentPrimary only writes on checkpointSecondary writes as changes are received(The same as Legacy DB Mirroring)

All compatibility modes are supportedNo Shared StorageMatching hardware is not required

AlwaysOn – A flexible solutionAlwaysOn provides the flexibility of different HA configurations

9

Synchronous Data Movement

Asynchcronous Data Movement

Shared Storage, regional and geo secondaries

A

AA

A

A

Direct attached storage local, regional and geo target

AA

Data TransferData is transferred via Data Mirroring

EndpointEndpoints created via the Wizard

automatically if not created

Configuration Options…Management Studio

Wizard Driven SetupPowerShell

CmdLets on the next slideT/SQL

CREATE AVAILABILITY GROUP – Setup Primary

ALTER AVAILABILITY GROUP – Join Secondary

PowerShell CmdLetsSetup

New-SqlAvailabilityGroup New-SqlAvailabilityReplica Add-SqlAvailabilityGroupDatabase Join-SqlAvailabilityGroup

Breakdown Remove-SqlAvailabilityGroup Remove-SqlAvailabilityGroupDatabase

Management Suspend-SqlAvailabilityGroup Switch-SqlAvailabilityGroup

Sample PowerShell Script to Configure HADR # Setup names and TCP addresses of the primary and secondary servers. $primaryServerName = "[PrimaryServerName]"; $secondaryServerName = "[SecondaryServerName]"; $primaryEndpointUrl = "TCP://" + $primaryServerName + ".web_domain:5022"; $secondaryEndpointUrl = "TCP://" + $secondaryServerName + ".web_domain:5022";

# Next create the Availability Replicas as templates. $replica1 = new-sqlavailabilityreplica -Name $primaryServerName -EndpointUrl

$primaryEndpointUrl -AsTemplate $replica2 = new-sqlavailabilityreplica -Name $secondaryServerName -EndpointUrl

$secondaryEndpointUrl -AsTemplate

# Finally create the Availability Group. $ag = new-sqlavailabilitygroup -Name $availabilityGroupName -AvailabilityReplica

($replica1, $replica2) -Database $databases

#Tells a secondary Server to join the Availability Group Join-SqlAvailabilityGroup -Path . -Name "My Availability Group"

Sorry About th

e Eye

Chart

Sorry About th

e Eye

Chart

Failing over AlwaysOnDone via SSMS. Switch-SqlAvailabilityGroup PowerShell

CmdLetALTER AVAILABILITY GROUP in T-SQL

http://www.flickr.com/photos/criminalintent/2569906181/

What can we use AlwaysOn for?Getting a backup of the database on a remote

machineTaking a snapshot of a databaseOffloading CheckDB from production serverOffloading reporting from production serverRedundancy - Dugh

Big Selling PointsSupport for up to 5 secondary servers

Up to 3 SynchronousUp to 5 Asynchronous

Backups on the secondary serversThe ability to fail over without data lossAutomatic FailoverRead Only routing to read only servers with

just a connection string and driver change on the client

LicensingEnterprise Only FeatureIf Read Only nodes are used by users then

licensing is required

Lets see how we set this thing up

Denny Cherrymrdenny@mrdenny.com

http://itke.techtarget.com/sql-serverhttp://twitter.com/mrdenny