balmukund lakhani technical lead – sql support | microsoft gtsc | [email protected] team...

52
High Availability options Explored with SQL Server Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC http://blogs.msdn.com/blakhani | [email protected] Team Blog – http://blogs.msdn.com/SQLServerFAQ

Upload: osborn-bailey

Post on 22-Dec-2015

220 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

High Availability options Explored with SQL Server

Balmukund LakhaniTechnical Lead – SQL Support | Microsoft GTSChttp://blogs.msdn.com/blakhani | [email protected] Blog – http://blogs.msdn.com/SQLServerFAQ

Page 2: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

About me…

Working with SQL Technology since 2001 (almost 10 years)Currently working as Technical Lead with Microsoft SQL Support team.Premier Field Engineer @ MicrosoftDeveloper @ Ramco SystemsDBA @ Ramco SystemsERP Onsite Support @ Ramco Systems

Page 3: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Agenda

Why High Availability?Backup/restore related technologies.Database SnapshotsLog-shippingDatabase MirroringFailover ClusteringReplicationSQL Server “Denali” High Availability

Page 4: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Business Needs

RTO (Recovery Time Objective)The duration of acceptable application downtime, whether from an unplanned outage or from scheduled maintenance/upgrades

RPO (Recovery Point Objective)The ability to accept potential data loss from an outage

Page 5: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Causes of Downtime and Data Loss

Planned Downtime*Performing database maintenancePerforming batch operationsPerforming an upgrade.

Unplanned DowntimeData center failureServer failureI/O subsystem failureHuman error

Page 6: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

What do we need?

Minimize or avoid service downtimeWhether planned or unplanned

When components fail,service interruption is brief or non-existent

Automatic failoverEliminate single points of failure (as affordable)

Redundant componentsFault-tolerant servers

Page 7: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Single-Instance Technologies

Page 8: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Backup, Restore, and Related Technologies

Partial Database Availability and Online Piecemeal RestoreInstant File InitializationMirrored BackupsBackup ChecksumsDatabase SnapshotsBackup Compression

Page 9: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Minimizing downtime

Backup Size

Backup Time

Restore Time

0

1

2

3

4

5

6

No CompressionCompression

Backup Compression

Backup compressi

on

Hot- Add CPU

Hot-Add memory

Online Operation

s

4.01GB

34.2 MB

295.8s

126.7s219s

126s

Page 10: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Database Snapshots

Page 11: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

What Are Database Snapshots?

Read-only, consistent view of a database

Specified point-in-time

Modifying dataCopy-on-write of affected pages

Reading dataAccesses snapshot if data has changedRedirected to original database otherwise

12:00 Snapshot

Page

Page

Page 12: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Using Database Snapshot to Recover Data

Scenario Example Code / Steps

Undeletingrows

Undoingan update

Recoveringa droppedobject

11 Script the object in the database snapshot

INSERT INTO Production.WorkOrderRoutingSELECT * FROM AdventureWorks_dbsnapshot_1800.Prod.WorkOrderRouting

INSERT INTO Production.WorkOrderRoutingSELECT * FROM AdventureWorks_dbsnapshot_1800.Prod.WorkOrderRouting

UPDATE HR.DepartmentSET Name = ( SELECT Name FROM AdventureWorks_dbsnapshot_1800.HR.Department WHERE DepartmentID = 1)WHERE DepartmentID = 1

UPDATE HR.DepartmentSET Name = ( SELECT Name FROM AdventureWorks_dbsnapshot_1800.HR.Department WHERE DepartmentID = 1)WHERE DepartmentID = 1

Caution: Not a substitute for a comprehensive backup and restore strategy

Execute the script in the source database22

Repopulate the object (if appropriate)33

Page 13: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Database Snapshot

Demo

Page 15: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Transaction log restore - Puzzle

Full backu

p 1 (12:00 PM)

T-Log backu

p 1 (1:00 PM)

T-Log backu

p 2 (2:00 PM)

T-Log backu

p 3 (3:00 PM)

Full backu

p 2 (3:25 PM)

T-Log backu

p 4 (3:35 PM)

03:22 PM

Page 16: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Multi-Instance Technologies

Page 18: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Log Shipping

Log shipping allows you to automatically send transaction log backups from one database to a secondary database on another serverLogs are restored automaticallySecondary server can be the failover server and can become primary if the main server goes down

Page 19: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Copy

Copy

Copy

Perform Backups

Copy and Restore Backups

RaiseAlerts

Primary Database

Monitor Database

Secondary Database

Secondary Database

Secondary Database

Copy and Restore Backups

Copy and Restore Backups

Log Shipping (in Action)

Page 20: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Strength & weakness

StrengthsCan Ship Logs Across WAN (Wide-Area Network)Protects an Entire Database

WeaknessesConfigured Per DatabaseNO AUTOMATIC FAILOVER

Page 21: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Log shipping

Demo

Page 22: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Database Mirroring

Page 23: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Database Mirroring How it works

MirrorPrincipal

Witness

Log

Application

SQL Server SQL Server

2

2

4

51

Data DataLog

3>2 >3

Mirror is always redoing – it remains currentCommit

Page 24: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Database Mirroring ModesHigh-Availability Mode

Safety Full; Synchronous operationDatabase is available whenever a quorum existsAutomatic failover

High-Protection ModeSafety Full; Synchronous operationNo witness – quorum provided by partnersIf Principal loses quorum, it stops servicing the database

Ensures high protection; database is never in ‘exposed’ state

Manual failover only; no automatic failoverA transition mode; should not be in this mode for long

High-Performance ModeSafety Off; Asynchronous operationManual failover only

Supports only one form of role switching: forced service (with possible data loss)

Page 25: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Principal

Witness

Data Log

Mirror

Data Log

1. Bad Page

DetectedX

2. Request page

3. Find page

4. Retrieve page

5. Transfer page6. Write

Page

DBM – Automatic Page Recovery

Client

Page 26: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

CPU goes up when compression is on, both because of compression/decompression, but also because the server can now process more transactions per second

Percentage increases in throughput is most dramatic for low network bandwidths

DBM – Log Compression

Page 27: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Strength & Weakness

StrengthsCan Mirror Across WANAutomatic Failover, and Nearly Instantaneous, Better than Failover ClusteringProtects an Entire Database

WeaknessesRequires Enterprise EditionMust be Configured Per Database

Page 28: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Mirroring Setup

Demo

Page 29: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Auto Page Repair

Demo

Page 30: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Failover Clustering

Page 31: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Virtual Server

Failover Clustering

Page 32: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Supports many scenarios: • Single Instance• Multiple Instance• Multiple Active Nodes• N+1• N+M

N+1: N Active, 1 Inactive Nodes

Inst2 *

* Inst1

Multiple Active Nodes

Inst2 *

* Inst1Inst3 *

N+M: N Active, M Inactive Nodes

Failover Cluster

* Inst1

SQL Server Cluster Topologies

Page 33: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Failover Clustering (Facts)Redundancy at database instance level

All databases fail over togetherShared copy of system databases

Single data copy on shared storage deviceNo I/O overhead reducing throughputStorage unit is single point of failure for cluster

All database services are clusteredSQL Agent; Analysis Services; Full-Text engine, MS DTC

Automatic failover (up to minutes)DBMS accessed over virtual IPStorage is controlled by one cluster node at a timeRequires hardware certified by Microsoft for Microsoft Cluster Service

Page 34: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Strength & Weakness

StrengthsProvides Protection Against a Node Failure, Protects the Entire SQL InstanceAutomatic Failover Supported

WeaknessesGenerally Expensive, Requires Specialty HardwareSpecialty Hardware RequirementsNot Trivial to Configure and ManageDoesn’t Protect Against a Complete

Site Failure

Page 36: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Replication

Primarily used where availability is required in conjunction with scale out of read activityFailover possible; a custom solutionNot limited to entire database; Can define subset of source database or tablesCopy of database is continuously accessible for read activityLatency between source and copy can be as low as seconds

Page 37: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Peer-to-Peer Replication

Provides high availability and read scalabilityBuilds redundancy by eliminating single point of failureEnable online upgrades of serversMaximize Application UptimeSupport for both Ring and Grid TopologyCentralized Management using Management Studio

Peer Node

Peer Node

Peer Node

Peer Node

Page 38: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

New Features

Application Server

Load BalancingRead

Write

Replicated Data

User Request

s

Add and remove nodes without stopping

Visual configuration with Topology Wizard

Ability to detect conflicts

Page 39: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Strength & Weakness

StrengthsPerpetual or on-demand replication of data, local or remoteProtects (duplicates or merges) the exact portion of the database I want

WeaknessesConfigured per database, even per tableGenerally does not protect or duplicate an entire Database

Page 40: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

SQL Server “Denali” High Availability

Page 41: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

SQL Server AlwaysOn

Increased Application Availability at Lower TCO with Ease of Use:

Multi-Database FailoverMultiple SecondariesActive Secondaries Fast Client Connection RedirectionWindows Server CoreMultisite Clustering

Page 42: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Availability Group Concepts

Availability GroupDefines the high availability requirements

Databases, Replicas, Availability Mode, Failover Mode etc

Availability ReplicaSQL Server Instances that are part of

the availability group which hosts the physical copy of the database

Role: Primary, Secondary, Resolving

Availability DatabaseSQL Server database that is part of an availability groupThis can be a regular database or contained database

Page 43: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Readable Secondary

Readable secondary allow offloading read queries to secondaryClose to real-time data, latency of log synchronization impact data freshness

DB2

DB1

SQLservr.exe

SQLservr.exe

InstanceA

DB2

DB1

Primary Secondary

Database Log Synchronization

InstanceB

Reports

Page 44: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

SQL Server “Denali” High Availability

• Configuration• Read-only Secondary

Demo

Page 45: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Comparing High Availability Technologies

CategoryAvailability

FeatureFailover

ClusteringDatabase Mirroring

Log Shipping Replication

Failover characteristics

Standby Type Hot Hot Warm Hot

Automatic role change

Yes Yes No No

Failover TypeAutomatic and

ManualAutomatic and

ManualManual Manual

Database Downtime during

failover

30 secs + database recovery

Less than 10 secs

Variable Variable

Physical Configuration

Redundant Storage

LocationsNo Yes Yes Yes

Hardware requirements

Microsoft certified cluster

solutionsStandard servers Standard servers Standard servers

Physical distance limit

100 miles None None None

Additional server role

None Witness Monitor Distributor

Page 46: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Comparing High Availability Technologies

CategoryAvailability

FeatureFailover

ClusteringDatabase Mirroring

Log Shipping

Replication

Management Complexity High Low Low Medium

Standby Accessible

NoVia Database

SnapshotsRead Only Yes

Multiple Secondaries

No No Yes Yes

Load delay on secondary

No No Yes No

Scope of Availability

Server Instance Database Database Database

Client Access Client redirect None requiredSupport in SNAC

and ADO.NET

Custom coding

required

Custom coding

required

Page 47: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

SummarySQL Server High Availability Technology

Database Server Failure or Disaster

Failover ClusteringDatabase MirroringPeer-to-Peer Replication

User or Application ErrorLog ShippingDatabase Snapshot

Data Access Concurrency Limitations

Snapshot IsolationOnline Index OperationsReplication

Database Maintenanceand Operations

Fast RecoveryPartial AvailabilityOnline RestoreMedia ReliabilityDedicated Administration ConnectionDynamic Configuration

Availability at ScaleData PartitioningReplication

TuningDatabase Tuning Advisor

Page 48: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

References

SQL Server Code Name Denali CTP1http://www.microsoft.com/sqlserver/en/us/product-info/future-editions.aspx SQL Server Books Online

Page 49: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Feedback / Q&A

Your Feedback is Important!Please take a few moments to fill out our

online feedback form at: www.virtualtechdays.com

For detailed feedback, use the form at http://www.connectwithlife.co.in/vtd/helpdesk.aspx

Or email us at [email protected]

Use the Question Manager on LiveMeeting to ask your questions now!

Page 50: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

Contact

Blog Addresshttp://blogs.msdn.com/BLakhani

http://blogs.msdn.com/SQLServerFAQ

Email [email protected]

Page 52: Balmukund Lakhani Technical Lead – SQL Support | Microsoft GTSC  | blakhani@microsoft.com Team Blog –

© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after

the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.