Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda...

56
Copyright 2009 all rights reserved Copyright 2009 all rights reserved 1 1 DB Architechs, USA DB Architechs, France Database Mirroring & Snapshots Database Mirroring & Snapshots SQL Server 2008 SQL Server 2008

Transcript of Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda...

Page 1: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

11DB Architechs, USADB Architechs, France

Database Mirroring & SnapshotsDatabase Mirroring & SnapshotsSQL Server 2008SQL Server 2008

Page 2: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Agenda Agenda –– SQL Server User GroupSQL Server User Group

�� Database Mirroring Database Mirroring –– SQL Server 2008SQL Server 2008

�� Database Mirroring 2005 vs 2008 Database Mirroring 2005 vs 2008 benchmarkbenchmark

�� Database Snapshots Database Snapshots –– SQL Server 2008SQL Server 2008

�� SQL Performance & Tuning Tool (SSV)SQL Performance & Tuning Tool (SSV)

Page 3: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

33

Paul BertucciPaul Bertucci�� Founder Database ArchitechsFounder Database Architechs�� Former Chief Data Architect Former Chief Data Architect –– Veritas & SymantecVeritas & Symantec�� Currently Chief Architect Currently Chief Architect -- AutodeskAutodesk�� Author of SQL Server 2000, 2005 & 2008 Unleashed! Author of SQL Server 2000, 2005 & 2008 Unleashed! �� CoCo--Author of ADO.NET in 24 hours Author of ADO.NET in 24 hours �� Author MS SQL Server High AvailabilityAuthor MS SQL Server High Availability�� Author Sybase Performance & TuningAuthor Sybase Performance & Tuning�� Author Sybase Physical DB DesignAuthor Sybase Physical DB Design�� Veritas SQL Server Performance Series Veritas SQL Server Performance Series

[email protected]@dbarchitechs.com

Thierry GerardinThierry Gerardin•• Managing Principal Managing Principal -- Database ArchitechsDatabase Architechs

-- Management, Research and Development, DB Design and P&T for Management, Research and Development, DB Design and P&T for MS SQL Server, Sybase and OracleMS SQL Server, Sybase and Oracle

•• European focus until recently/company growth leader European focus until recently/company growth leader –– multiple yearsmultiple years•• Expanding DB ARCH consulting practices to USA and AsiaExpanding DB ARCH consulting practices to USA and Asia•• Sybase P&T and DBA Certified ProfessionalSybase P&T and DBA Certified Professional•• Contributor to SQL Server 2005 Unleashed!Contributor to SQL Server 2005 Unleashed!

[email protected]@dbarchitechs.com

Database ArchitechsDatabase ArchitechsPrincipals

Page 4: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

44

Database ArchitechsDatabase ArchitechsPrimary ServicesPrimary Services

Database Design

Data Analysis & Modeling

Data Architecture

Performance &Tuning

High Availability

Master Data Management

Distributed Data & Data Replication

Business Intelligence &Data Delivery

Platforms

Database Education& Training

Page 5: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Past and CurrentPast and CurrentIntel Applied MaterialsCisco Apple ComputersCharles Schwab PG&EAplia Thomson LearningAGIS SybaseVeritas Symantec CorporationHonda Motors Nissan MotorsToshiba Computers Breg InternationalJuniper Networks CSAASafeway Stores Federal ExpressWells Fargo Bank of AmericaRobert Half Merrill LynchMetalinc many others….

Customers

Page 6: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Database Mirroring?Database Mirroring?

A “complete” copy of a database that is created and maintained with as up to the second completenessthat is possible � a mirror image.

Adventure Works DB = Adventure

Works DB

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

66

What’s new or improved?� Compression in log transactions across topology� Various other performance enhancements� Page fixing on the mirror side (AUTO)� 3 years of production execution success!

Page 7: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

77

SQL Server 2008

“Source”

CallOne DB

CallOne DB

SQL Server 2008

SecondaryServer

“Destination”

translog

\Backup\CallOne_tlog_200405141120.TRN

TxnLogbackupsPrimary

Server

TxnLog Copies

\LogShare\CallOne_tlog_200405141120.TRN TxnLog Restores

MSDB DB

SQL Server 2008

MonitorServer

“Monitor”

Last

log

ship

ped

Del

ay A

nsw

er

Delay between logs loaded

Delay Answer

Log ShippingLog Shipping

Don’t build on this, it is being deprecated !

Page 8: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

88

DB DB MirroringMirroring

MSDB DB

SQL Server 2008

SQL Server xyz

WitnessServer

Adventure Works DB

SQL Server 2008

Mirror Server

translog

PrincipalServer

translog

Adventure Works DB

Network

Client Client ClientClient

B

C

A

DD

Page 9: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

CopyCopy--onon--write Technologywrite TechnologyThe new “copy-on-write” technology that Microsoft has created, is at the core of the database mirroring capability. A transaction from a client connection to the principal server (arrow label A) is written to the adventure works database (label D). Once the transaction is written to the principal servers transaction log, it is immediately copied (arrow label B) and written to the Mirror Server (also labeled D). When this physical log record is written to the mirror server, it sends back an acknowledgement (arrow label C) to the principal of its write success. This is the “copy-on-write” technology. The end result is that the mirror server is in the exact same state as the principal server (when the physical log record has been successfully written on the mirror side).

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

99

Page 10: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

DB Mirroring TermsDB Mirroring TermsThe Principal database server - is the source of the mirroring. You can mirror one or more databases on a single SQL Server instance to another SQL Server instance. You cannot mirror a database on one SQL Server instance to itself (the same SQL Server instance).

The Mirror database server - will be the recipient of the mirroring from the principal database server. This mirrored database will be kept in a hot standby mode and cannot be used directly in any way. In fact, once you have configured database mirroring, this database will show its status as in continuous “restore mode”.

The Witness database server - is used when you want to be continuously checking to see if any failures have occurred to the primary database server and to help make the decision to failover to the mirror database server. It is optional, but a sound way to configure database mirroring. If you do not identify a witness server, the principal and mirror are left on their own to decide to fail-over or not.

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

1010

Page 11: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

DB Mirroring ModesDB Mirroring ModesHigh-availability mode, High-protection mode, and H igh-performance mode.

Synchronous operation - a committed transaction will be committed (written) onboth partners of the database mirroring pair. This obviously adds some latency costto a complete transaction (it is across two servers). High-availability mode and High-protection mode use synchronous operations (termed High safety)

Asynchronous operation - transactions commit without waiting for the mirror serverto write the log to disk. This can speed up performance significantly. High-performance mode uses asynchronous operations.

Whether the operations are asynchronous or synchronous depends on the “transaction safety” setting. This is controlled by the SAFETY option when configuring with Transact-SQL commands (Set to FULL for synchronous operations, set to OFF for asynchronous operations).

[you must sacrifice levels of protection for performance]

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

1111

Page 12: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

FailFail--over methodsover methodsAutomatic failover - is enabled with a three-server configuration; a principal, a mirror, and a witness server. Synchronous operations are required and the mirror database must already be synchronized (in sync with the transactions as they are being written to the principal). Role switching is done automatically. This is for high-availabilit y mode.

Manual failover - is needed when there is no witness server and is also doing synchronous operations. The principal and the mirror are connected to each other and the mirror database must already be synchronized. Role switching is done manually. This is for high-protection mode.

Forced Service - in the case where there is a mirror server available, but it might not be synchronized. It can be forced to take over when the principal server has failed. This will possibly have data loss, since the transactions were not synchronized. This is for either high-protection or high-performance mode.

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

1212

Page 13: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

RuleRule--ofof--ThumbThumb

• If you need to increase the availability of the database layer• If you need to have automatic data protection (redundant storage of data)• If you need to decrease the downtime that would normally be required to

do upgrades

You should use database mirroring:

And very often:• If you need to off load reporting (periodic data snapshots) without impacting the transactional system use database mirroring with database snapshots.• Combo Needs: If you need data distribution, high availability and high data resiliency - use data replication with database mirroring.

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

1313

Page 14: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Cannot be used with:Cannot be used with:

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

1414

Database Mirroring cannot be used for any of SQL Server’s internal databases � TempDB, Master DB, MSDB, or Model DB.

Database Mirroring is NOT supported in SQL Server Workgroup Edition or Express Edition. However, these server editions could be used as Witness servers.

You cannot have database mirroring for databases enabled with FILESTREAM storage.

Page 15: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

1515

HAHA

Extreme Availability

High Availability

Standard Availability

Acceptable Availability

Marginal Availability

Near zero downtime!

Minimal downtime

With some downtimetolerance

Non-critical Applications

Non-production Applications

8,760 hours/year | 168 hours/week | 24 hours/day525,600 minutes/year | 7,200 minutes/week | 1,440 minutes/day

(99.5% - 100%)

(95% - 99.4%)

(83% - 94%)

(70%-82%)

(up to 69%)

Characteristic Availability Range

Availability Range describes the percentage of time relative to the “p lanned” hours of operations

Availability Continuum

Page 16: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Windows 2003 EE

Windows 2003 EE

SQL Server 2008 (Virtual SQL Server) SCSI

LocalBinaries

LocalBinaries

CLUSTER1

SQL Clustering basic configurationSQL Clustering basic configuration

S:

C:

C:

Master DBTempDBAppl 1 DB

CLUSTER2

SQL Server 2008 (physical)

SQL Server 2008 (physical)

SQLConnections

Quorum Disk

Q:VSQLSERVER2008

Cluster GroupResources

MS DTCSQL Agent

MSCS

MSCS

SQL Full TextSearch

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

1616

Page 17: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

1717

Example Example ConfiguratioConfiguratio

nn

MSDB DB

SQL Server 2008

SQL Server 2008

WitnessServer

Adventure Works DB

SQL Server 2008

Mirror Server

translog

PrincipalServer

translog

Adventure Works DB

Instance: SQL08DE01 Instance: SQL08DE02

Instance: SQL08DE03

Endpoint name: “EndPoint4DBMirroring1430” Endpoint name: “EndPoint4DBMirroring1440”

Endpoint name: “EndPoint4DBMirroring1450”

TCP: Listener_Port: 1430 TCP: Listener_Port: 1440

TCP: Listener_Port: 1450

Role: PARTNER Role: PARTNER

Role: WITNESS

Page 18: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

11

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

1818

Page 19: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

22

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

1919

Page 20: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

33

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

2020

Page 21: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Creating EndpointsCreating Endpoints-- create endpoint for PRINCIPAL server --CREATE ENDPOINT [EndPoint4DBMirroring1430]

STATE=STARTEDAS TCP (LISTENER_PORT = 1430, LISTENER_IP = ALL)FOR DATA_MIRRORING (ROLE = PARTNER,

AUTHENTICATION = WINDOWS NEGOTIATE, ENCRYPTION = REQUIRED ALGORITHM RC4)

01/05/2009 13:17:23,spid55,Unknown,The Database Mirroring protocol transport is now listening for connections.01/05/2009 13:17:23,spid55,Unknown,Server is listening on [ 'any' <ipv4> 1430].

SQL Server Log entry

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

2121

Page 22: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Creating EndpointsCreating Endpoints-- create endpoint for MIRROR server --CREATE ENDPOINT [EndPoint4DBMirroring1440]

STATE=STARTEDAS TCP (LISTENER_PORT = 1440, LISTENER_IP = ALL)FOR DATA_MIRRORING (ROLE = PARTNER,

AUTHENTICATION = WINDOWS NEGOTIATE, ENCRYPTION = REQUIRED ALGORITHM RC4)

-- create endpoint for WITNESS server --CREATE ENDPOINT [EndPoint4DBMirroring1450]

STATE=STARTEDAS TCP (LISTENER_PORT = 1450, LISTENER_IP = ALL)FOR DATA_MIRRORING (ROLE = WITNESS,

AUTHENTICATION = WINDOWS NEGOTIATE, ENCRYPTION = REQUIRED ALGORITHM RC4)

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

2222

Page 23: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Backup PrincipalBackup Principal�� BACKUP DATABASE [AdventureWorks] BACKUP DATABASE [AdventureWorks]

�� TO DISK = N'C:TO DISK = N'C:\\Program FilesProgram Files\\Microsoft SQL Microsoft SQL ServerServer\\MSSQL10.SQL08DE01MSSQL10.SQL08DE01\\MSSQLMSSQL\\BackupBackup\\AdventureWorks4Mirror.bak'AdventureWorks4Mirror.bak'

�� WITH FORMATWITH FORMAT

�� GOGO

�� ---- Processed 17672 pages for database 'AdventureWorks', file 'AdveProcessed 17672 pages for database 'AdventureWorks', file 'AdventureWorks_Data' on file 1.ntureWorks_Data' on file 1.

�� ---- Processed 3 pages for database 'AdventureWorks', file 'AdventurProcessed 3 pages for database 'AdventureWorks', file 'AdventureWorks_Log' on file 1.eWorks_Log' on file 1.

�� ---- BACKUP DATABASE successfully processed 17675 pages in 7.718 secBACKUP DATABASE successfully processed 17675 pages in 7.718 seconds (17.890 MB/sec).onds (17.890 MB/sec).

�� BACKUP LOG [AdventureWorks] TO BACKUP LOG [AdventureWorks] TO

�� DISK = N'C:DISK = N'C:\\Program FilesProgram Files\\Microsoft SQL Microsoft SQL ServerServer\\MSSQL10.SQL08DE01MSSQL10.SQL08DE01\\MSSQLMSSQL\\BackupBackup\\AdventureWorks4MirrorLog.bak' AdventureWorks4MirrorLog.bak'

�� GOGO

�� ---- Processed 1849 pages for database 'AdventureWorks', file 'AdvenProcessed 1849 pages for database 'AdventureWorks', file 'AdventureWorks_Log' on file 1.tureWorks_Log' on file 1.

�� ---- BACKUP LOG successfully processed 1849 pages in 0.862 seconds (BACKUP LOG successfully processed 1849 pages in 0.862 seconds (16.757 MB/sec).16.757 MB/sec).

Page 24: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Restore to MirrorRestore to Mirror�� RESTORE FILELISTONLY RESTORE FILELISTONLY

�� FROM DISK = N'C:FROM DISK = N'C:\\Program FilesProgram Files\\Microsoft SQL Microsoft SQL ServerServer\\MSSQL10.SQL08DE01MSSQL10.SQL08DE01\\MSSQLMSSQL\\BackupBackup\\AdventureWorks4Mirror.bak'AdventureWorks4Mirror.bak'

�� RESTORE DATABASE AdventureWorks RESTORE DATABASE AdventureWorks

�� FROM DISK = N'C:FROM DISK = N'C:\\Program FilesProgram Files\\Microsoft SQL Microsoft SQL ServerServer\\MSSQL10.SQL08DE01MSSQL10.SQL08DE01\\MSSQLMSSQL\\BackupBackup\\AdventureWorks4Mirror.bak'AdventureWorks4Mirror.bak'

�� WITH NORECOVERY, WITH NORECOVERY,

�� MOVE 'AdventureWorks_Data' TO 'C:MOVE 'AdventureWorks_Data' TO 'C:\\Program FilesProgram Files\\Microsoft SQL Microsoft SQL ServerServer\\MSSQL10.SQL08DE02MSSQL10.SQL08DE02\\MSSQLMSSQL\\DATADATA\\AdventureWorks_Data.mdf',AdventureWorks_Data.mdf',

�� MOVE 'AdventureWorks_Log' TO 'C:MOVE 'AdventureWorks_Log' TO 'C:\\Program FilesProgram Files\\Microsoft SQL Microsoft SQL ServerServer\\MSSQL10.SQL08DE02MSSQL10.SQL08DE02\\MSSQLMSSQL\\DATADATA\\AdventureWorks_Log.ldf'AdventureWorks_Log.ldf'

�� GOGO�� ---- Processed 17672 pages for database 'AdventureWorks', file 'AdveProcessed 17672 pages for database 'AdventureWorks', file 'AdventureWorks_Data' on file 1.ntureWorks_Data' on file 1.

�� ---- Processed 3 pages for database 'AdventureWorks', file 'AdventurProcessed 3 pages for database 'AdventureWorks', file 'AdventureWorks_Log' on file 1.eWorks_Log' on file 1.

�� ---- RESTORE DATABASE successfully processed 17675 pages in 6.716 seRESTORE DATABASE successfully processed 17675 pages in 6.716 seconds (20.560 MB/sec).conds (20.560 MB/sec).

�� RESTORE LOG AdventureWorksRESTORE LOG AdventureWorks

�� FROM DISK = N'C:FROM DISK = N'C:\\Program FilesProgram Files\\Microsoft SQL Microsoft SQL ServerServer\\MSSQL10.SQL08DE01MSSQL10.SQL08DE01\\MSSQLMSSQL\\BackupBackup\\AdventureWorks4MirrorLog.bak'AdventureWorks4MirrorLog.bak'

�� WITH FILE = 1, NORECOVERY;WITH FILE = 1, NORECOVERY;

�� GOGO�� ---- Processed 0 pages for database 'AdventureWorks', file 'AdventurProcessed 0 pages for database 'AdventureWorks', file 'AdventureWorks_Data' on file 1.eWorks_Data' on file 1.

�� ---- Processed 1849 pages for database 'AdventureWorks', file 'AdvenProcessed 1849 pages for database 'AdventureWorks', file 'AdventureWorks_Log' on file 1.tureWorks_Log' on file 1.

�� ---- RESTORE LOG successfully processed 1849 pages in 1.083 seconds RESTORE LOG successfully processed 1849 pages in 1.083 seconds (13.338 MB/sec).(13.338 MB/sec).

Page 25: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

77

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

2525

Page 26: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

99

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

2626

Page 27: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

1111

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

2727

Page 28: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

1212

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

2828

Page 29: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

1313

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

2929

Page 30: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

1414

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

3030

Page 31: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

1515

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

3131

Page 32: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

1616

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

3232

Page 33: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

PH TopologyPH Topology

SQL Server 2008

Adventure Works DB

SQL Server 2008

Mirror Server

translog

PrincipalServer

translog

Adventure Works DB

Instance: SQL2008xyz

Instance: SQL2008zzz

Endpoint Name: “endpoint4mirroring”

Endpoint Name: “endpoint4mirroring”

Role: PARTNER

Role: PARTNER

PH Topology

SQL Server 2008

PrincipalServer

Active

Passive

Clu

ster

ed

OLT

P A

pplic

atio

n

Rep

licat

ion

Page 34: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

DB Mirroring 2005 BenchmarksDB Mirroring 2005 Benchmarks

Send Rate

Repl_rows stored procedure 9999999

Page 35: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

DB Mirroring 2008 BenchmarksDB Mirroring 2008 Benchmarks

Send Rate

41% More

Page 36: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

DB Mirroring 2005 BenchmarksDB Mirroring 2005 Benchmarks

Restore Rate

Page 37: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

DB Mirroring 2008 BenchmarksDB Mirroring 2008 Benchmarks

Restore Rate

52% more

Page 38: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

DB Mirroring 2005 BenchmarksDB Mirroring 2005 Benchmarks

Page 39: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

DB Mirroring 2008 BenchmarksDB Mirroring 2008 Benchmarks

Page 40: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

4040

DB Mirroring Benchmark SummaryDB Mirroring Benchmark Summary

Overall send rate 41 % faster (2005 vs 2008)Overall restore rate 52% faster (2005 vs 2008)

Overall availability topology inherits the restore rate ~ 50% more available

Example:743 ms Transaction (in 2005 mirroring configuration)379 ms Transaction (in 2008 mirroring configuration)

In failover, what would have been 20 seconds before mirror becomes principalturns into roughly 8-10 seconds (or 3seconds turns into 1.5 seconds, so on).

Page 41: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

4141

SnapshotsSnapshots

Page 42: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

0101SQL Server 2008

AdventureWorks DB

translog

SourceServer

Database Snapshot

Point-i

n-tim

e

Repor

ting

Users

(Rea

d-Only

)

Transactional

Users

--- Reverting --- if needed ---RESTORE DB

AdventureWorksFROM DATABASE_SNAPSHOT = ‘xyz’

CREATE DB ‘xyz’AS SNAPSHOT OF

AdventureWorks

Page 43: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

4343

0202SQL Server 2008

SQLServer

AdventureWorks DB

SnapshotAdventureWork

s DB

Source DataPages

Empty Sparse fileof a Snapshot just created

(no updates to original data pages have occurred yet)

SparseFile

Pages

Source

Page 44: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

4444

0303SQL Server 2008

SQLServer

AdventureWorks DB

SnapshotAdventureWork

s DB

SourceData

Pages

System Catalogof changed pages

Copy of originalpages for snapshot

only when a page is changed(Copy-on-write)

SparseFile

Pages

Source

Page 45: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

4545

0404SQL Server 2008

SQLServer

AdventureWorks DB

SnapshotAdventureWork

s DB

Source DataPages

System Catalogof changed pages

SparseFile

Pages

SELECT …..data…… . FROM AdventureWorks

SNAPSHOT

Snapshot Users

Page 46: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

0505SQL Server 2008

SQLServer

AdventureWorks DB

SnapshotAdventureWork

s DB

DataPages

System Catalogof changed pages Copy of original

pages for snapshot useonly when a page is changed

(Copy-on-write)

SparseFile

Pages

Transactional Users

translog

Upd

ate

Row

A

B

B

B

B

C

Com

mitt

ed

Page 47: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

0606SQL Server 2008

AdventureWorksDB

translog

SourceServer

Database Snapshot

AllUsers

Database Snapshot

Database Snapshot

6:00AM Snapshot

12:00PM Snapshot

6:00PM SnapshotRestore fromAny Point-in-time

Snapshot if neededDatabase Snapshot

12:00AM Snapshot

UPDATE AWSource.tableXset xyz = …

FROM AWSnapshot6:00AM.tableX

Page 48: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

0707SQL Server 2008

AdventureWorksDB

SourceServer

Database Snapshot

Users

SAFEGUARD Snapshot(Before the mass changes)Restore from snapshot

(if changes are not correct)

GeneratingMass Changes

UPDATE AWSource.tableXset xyz = …

FROM AWSafegaurd6:00AM.tableX

Page 49: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

0808SQL Server 2008

AdventureWorksDB

SourceServer

Database Snapshot

Testing Users

BEFORE TEST Snapshot

Restore from the BEFORE snapshotafter testing cycle is complete and can

continue with next test.

Page 50: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

0909SQL Server 2008

AdventureWorksDB

translog

SourceServer

Database Snapshot

Transactional

Users

Database Snapshot

Database Snapshot

6:00AM Reporting Snapshot

12:00PM Reporting Snapshot

6:00PM Reporting SnapshotDatabase Snapshot

12:00AM Reporting Snapshot

Point-in-time

Reporting Users

(Read-Only)

Page 51: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

5151

1010

MSDB DB

SQL Server 2008

SQL Server 2008

WitnessServer

AdventureWorksDB

SQL Server 2008

Mirror Server

translog

PrincipalServer

Networ

k

Networ

k

Database Snapshot

Repor

ting

Users

AdventureWorksDB

translogDatabase Snapshot

If th

is s

erve

r no

de

beco

mes

the

mirr

or.

Page 52: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

5252

PH Topology With SnapshotsPH Topology With Snapshots

SQL Server 2008

Adventure Works DB

SQL Server 2008

Mirror Server

translog

PrincipalServer

translog

Adventure Works DB

Instance: SQL2008xyz

Instance: SQL2008zzz

Endpoint Name: “endpoint4mirroring”

Endpoint Name: “endpoint4mirroring”

Role: PARTNER

Role: PARTNER

PH Topology

SQL Server 2008

PrincipalServer

Active

Passive

Clu

ster

ed

OLT

P A

pplic

atio

n

Rep

licat

ion

NetworkNetwork

Reporting Users

Database Snapshot

Page 53: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

5353

DB Mirror and DB Mirror and ReplicationReplicationSQL Server 2008

PrincipalServer

SQL Server 2008

MirrorServer

SQL Server 2008

WitnessServer

SQL Server 2008

PrincipalServer

SQL Server 2008

MirrorServer

SQL Server 2008

Subscriber

SQL Server 2008

Subscriber

Publisher

Distributor

Page 54: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

5454

Distributing DataDistributing DataData Access Latency Autonomy Sites(locations)

Frequency Network Machines Owner Other

Read OnlyReporting short high many high fast/

stable1

server/site1 OLTP

site

Each site only needs regionaldata

Central PublisherTransactional replfilter by region

REPLICATION

Read OnlyReporting long high many low fast/

stable1

server/site1 OLTP

site

Each site only needs regionaldata

Central PublisherSnapshot replfilter by region

Read MostlyA few updates short high < 10 medium fast/

stable1

server/site1 OLTP

site

Regional updateson one table

Central PublisherTransactional replUpdating Subs

Read MostlyA few updates medium high < 10 medium slow/

unreliab1

server/siteAll

update

Regional updateall tables

Central PublisherMerge repl

Inserts (new orders) short high many high fast/

stable1

server/site

1reportsite

Each site only needs regionaldata

Central SubscriberTransactional repl

Hot/WarmSpare

Veryshort

high < 2 high fast/stable

1server/site

1 OLTPsite

Fail-overCentral PublisherRemote DistributorTransactional repl

Read equalEqual updates short high < 10 medium fast/

stable1

server/siteAll

update

Regional updateall tables

Peer-to-PeerTransactional

repl

Database Mirroring

Database Mirroring

Database Mirroring

Page 55: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

Copyright 2009 all rights reservedCopyright 2009 all rights reserved

QuestionsQuestionsIs there any time left????

Send your questions to: [email protected]

[email protected]

Page 56: Database Mirroring & Snapshots SQL Server 2008files.meetup.com/1381968/PaulBertucci_Feb09.pdfAgenda – SQL Server User Group Database Mirroring – SQL Server 2008 Database Mirroring

ProductsProductsDatabase Products

SQL SuperVision SQL SuperVision –– SybaseSybaseSQL SuperVision SQL SuperVision –– OracleOracle

SQL SuperVision SQL SuperVision –– MS SQL ServerMS SQL Server