Download - Db Mirroring
-
7/27/2019 Db Mirroring
1/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved
11DB Architechs, USADB Architechs, France
Database Mirroring & SnapshotsDatabase Mirroring & Snapshots
SQL Server 2008SQL Server 2008
-
7/27/2019 Db Mirroring
2/56
AgendaAgendaSQL Server User GroupSQL Server User Group
Database MirroringDatabase MirroringSQL Server 2008SQL Server 2008
Database Mirroring 2005 vs 2008Database Mirroring 2005 vs 2008 benchmarkbenchmark
Database SnapshotsDatabase SnapshotsSQL Server 2008SQL Server 2008
SQL Performance &SQL Performance &Tuning Tool (SQL Shot !)Tuning Tool (SQL Shot !)
-
7/27/2019 Db Mirroring
3/56
-
7/27/2019 Db Mirroring
4/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved44
Database ArchitechsDatabase Architechs
Primary ServicesPrimary Services
Database Design
Data Analysis& Modeling
Data Architecture
Performance &Tuning
High Availability
Master DataManagement
Distributed Data &Data Replication
Business Intelligence &Data Delivery
Platforms
Database Education& Training
-
7/27/2019 Db Mirroring
5/56
Past and CurrentPast and Current
Intel Applied Materials
Cisco Apple Computers
Charles Schwab PG&E
Aplia Thomson Learning
AGIS Sybase
Veritas Symantec Corporation
Honda Motors Nissan MotorsToshiba Computers Breg International
Juniper Networks CSAA
Safeway Stores Federal Express
Wells Fargo Bank of AmericaRobert Half Merrill Lynch
Metalinc many others.
Customers
-
7/27/2019 Db Mirroring
6/56
Database Mirroring?Database Mirroring?
A complete copy of a database that is created andmaintained with as up to the second completenessthat is possible a mirror image.
AdventureWorks DB = AdventureWorks DB
Copyright 2009 all rights reservedCopyright 2009 all rights reserved
66
Whats 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!
-
7/27/2019 Db Mirroring
7/56
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
TxnLog
backupsPrimaryServer
TxnLogCopies
\LogShare\CallOne_tlog_200405141120.TRN TxnLogRestores
MSDB DB
SQL Server 2008
MonitorServer
Monitor
Lastlogshipped
DelayAnswer
Delay betweenlogs loaded
Delay Answer
Log ShippingLog Shipping
Dont build on this, it is being deprecated !
-
7/27/2019 Db Mirroring
8/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved
88
DBDB
MirroringMirroring
MSDB DB
SQL Server 2008
SQL Server xyz
WitnessServer
Adventure
Works DB
SQL Server 2008
Mirror Server
translog
Principal
Server
translog
Adventure
Works DB
Network
Client Client ClientClient
B
C
A
D
D
-
7/27/2019 Db Mirroring
9/56
CopyCopy--onon--write Technologywrite TechnologyThe new copy-on-write technology that Microsoft has created, is at the core ofthe 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 (alsolabeled D). When this physical log record is written to the mirror server, it sendsback 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 recordhas been successfully written on the mirror side).
Copyright 2009 all rights reservedCopyright 2009 all rights reserved
99
-
7/27/2019 Db Mirroring
10/56
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 SQLServer instance).
The Mirror database server - will be the recipient of the mirroring from the principaldatabase server. This mirrored database will be kept in a hot standby mode andcannot 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 checkingto see if any failures have occurred to the primary database server and to help makethe decision to failover to the mirror database server. It is optional, but a sound wayto 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
-
7/27/2019 Db Mirroring
11/56
DB Mirroring ModesDB Mirroring ModesHigh-availability mode, High-protection mode, and High-performance mode.
Synchronous operation - a committed transaction will be committed (written) on
both partners of the database mirroring pair. This obviously adds some latency costto a complete transaction (it is across two servers). High-availability mode andHigh-protection mode use synchronous operations (termed High safety)
Asynchronous operation - transactions commit without waiting for the mirror server
to 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 thetransaction safety setting. This is controlled by the SAFETY option whenconfiguring with Transact-SQL commands (Set to FULL for synchronousoperations, set to OFF for asynchronous operations).
[you must sacrifice levels of protection for performance]
Copyright 2009 all rights reservedCopyright 2009 all rights reserved
1111
-
7/27/2019 Db Mirroring
12/56
FailFail--over methodsover methodsAutomatic failover - is enabled with a three-server configuration; a principal, amirror, 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-availability mode.
Manual failover - is needed when there is no witness server and is also doingsynchronous operations. The principal and the mirror are connected to each other
and the mirror database must already be synchronized. Role switching is donemanually. This is for high-protection mode.
Forced Service - in the case where there is a mirror server available, but it mightnot 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 notsynchronized. This is for either high-protection or high-performance mode.
Copyright 2009 all rights reservedCopyright 2009 all rights reserved
1212
-
7/27/2019 Db Mirroring
13/56
-
7/27/2019 Db Mirroring
14/56
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 Servers internaldatabases TempDB, Master DB, MSDB, or Model DB.
Database Mirroring is NOT supported in SQL Server WorkgroupEdition or Express Edition. However, these server editions could beused as Witness servers.
You cannot have database mirroring for databases enabled withFILESTREAM storage.
-
7/27/2019 Db Mirroring
15/56
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/day
525,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 Rangedescribes the percentage of time relative to the planned hours of operations
Availability Continuum
-
7/27/2019 Db Mirroring
16/56
Windows 2003 EE
Windows 2003 EE
SQL Server 2008
(Virtual SQL Server) SCSI
Local
Binaries
LocalBinaries
CLUSTER1
SQL Clustering basic configurationSQL Clustering basic configuration
S:
C:
C:
Master DB
TempDBAppl 1 DB
CLUSTER2
SQL Server 2008 (physical)
SQL Server 2008 (physical)
SQL
Connections
QuorumDisk
Q:
VSQLSERVER2008
Cluster Group
Resources
MS DTCSQL Agent
MSCS
MSCS
SQL Full TextSearch
Copyright 2009 all rights reservedCopyright 2009 all rights reserved1616
-
7/27/2019 Db Mirroring
17/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved1717
ExampleExample
ConfiguratioConfiguratio
nn
MSDB DB
SQL Server 2008
SQL Server 2008
Witness
Server
Adventure
Works DB
SQL Server 2008
Mirror Server
translog
Principal
Server
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
-
7/27/2019 Db Mirroring
18/56
11
Copyright 2009 all rights reservedCopyright 2009 all rights reserved1818
-
7/27/2019 Db Mirroring
19/56
22
Copyright 2009 all rights reservedCopyright 2009 all rights reserved1919
-
7/27/2019 Db Mirroring
20/56
33
Copyright 2009 all rights reservedCopyright 2009 all rights reserved2020
-
7/27/2019 Db Mirroring
21/56
Creating EndpointsCreating Endpoints
-- create endpoint for PRINCIPAL server --CREATE ENDPOINT [EndPoint4DBMirroring1430]
STATE=STARTED
AS 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 forconnections.01/05/2009 13:17:23,spid55,Unknown,Server is listening on [ 'any' 1430].
SQL Server Log entry
Copyright 2009 all rights reservedCopyright 2009 all rights reserved2121
-
7/27/2019 Db Mirroring
22/56
Creating EndpointsCreating Endpoints-- create endpoint for MIRROR server --CREATE ENDPOINT [EndPoint4DBMirroring1440]
STATE=STARTED
AS 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=STARTED
AS 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 reserved2222
-
7/27/2019 Db Mirroring
23/56
Backup PrincipalBackup Principal BACKUP DATABASE [AdventureWorks]BACKUP DATABASE [AdventureWorks]
TO DISK = N'C:TO DISK = N'C:\\Program FilesProgram Files\\Microsoft SQLMicrosoft 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] TOBACKUP LOG [AdventureWorks] TO
DISK = N'C:DISK = N'C:\\Program FilesProgram Files\\Microsoft SQLMicrosoft 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).
-
7/27/2019 Db Mirroring
24/56
-
7/27/2019 Db Mirroring
25/56
77
Copyright 2009 all rights reservedCopyright 2009 all rights reserved2525
-
7/27/2019 Db Mirroring
26/56
99
Copyright 2009 all rights reservedCopyright 2009 all rights reserved2626
-
7/27/2019 Db Mirroring
27/56
1111
Copyright 2009 all rights reservedCopyright 2009 all rights reserved2727
-
7/27/2019 Db Mirroring
28/56
1212
Copyright 2009 all rights reservedCopyright 2009 all rights reserved2828
-
7/27/2019 Db Mirroring
29/56
1313
Copyright 2009 all rights reservedCopyright 2009 all rights reserved2929
-
7/27/2019 Db Mirroring
30/56
1414
Copyright 2009 all rights reservedCopyright 2009 all rights reserved3030
-
7/27/2019 Db Mirroring
31/56
1515
Copyright 2009 all rights reservedCopyright 2009 all rights reserved3131
-
7/27/2019 Db Mirroring
32/56
1616
Copyright 2009 all rights reservedCopyright 2009 all rights reserved3232
Instance: SQL2008xyz
-
7/27/2019 Db Mirroring
33/56
PH TopologyPH Topology
SQL Server 2008
AdventureWorks DB
SQL Server 2008
Mirror Server
translog
Principal
Server
translog
AdventureWorks DB
Instance: SQL2008xyz
Instance: SQL2008zzz
Endpoint Name: endpoint4mirroring
Endpoint Name: endpoint4mirroring
Role: PARTNER
Role: PARTNER
PHTopology
SQL Server 2008
Principal
Server
Active
Passive
Cluste
red
OLTPApp
lication
Replica
tion
-
7/27/2019 Db Mirroring
34/56
DB Mirroring 2005 BenchmarksDB Mirroring 2005 Benchmarks
Send Rate
Repl_rows stored procedure 9999999
-
7/27/2019 Db Mirroring
35/56
DB Mirroring 2008 BenchmarksDB Mirroring 2008 BenchmarksSend Rate
41% More
-
7/27/2019 Db Mirroring
36/56
DB Mirroring 2005 BenchmarksDB Mirroring 2005 Benchmarks
Restore Rate
-
7/27/2019 Db Mirroring
37/56
DB Mirroring 2008 BenchmarksDB Mirroring 2008 BenchmarksRestore Rate
52% more
-
7/27/2019 Db Mirroring
38/56
DB Mirroring 2005 BenchmarksDB Mirroring 2005 Benchmarks
-
7/27/2019 Db Mirroring
39/56
DB Mirroring 2008 BenchmarksDB Mirroring 2008 Benchmarks
-
7/27/2019 Db Mirroring
40/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved4040
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 3 seconds turns into 1.5 seconds, so on).
-
7/27/2019 Db Mirroring
41/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved4141
SnapshotsSnapshots
-
7/27/2019 Db Mirroring
42/56
0101SQL Server 2008
AdventureWork
s DB
translog
Source
Server
DatabaseSnapshot
Point-i
n-time
Repo
rting
Users
(Rea
d-Only)
Transactional
Users
--- Reverting --- if needed ---RESTORE DB
AdventureWorksFROM DATABASE_SNAPSHOT = xyz
CREATE DB xyzAS SNAPSHOT OF
AdventureWorks
-
7/27/2019 Db Mirroring
43/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved4343
0202SQL Server 2008
SQLServer
AdventureWork
s DB
SnapshotAdventureWork
s DB
Source Data
Pages
Empty Sparse fileof a Snapshot just created
(no updates to originaldata pages have occurred yet)
SparseFile
Pages
Source
S
-
7/27/2019 Db Mirroring
44/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved4444
0303SQL Server 2008
SQLServer
AdventureWork
s DB
SnapshotAdventureWork
s DB
SourceData
Pages
System Catalog
of changed pages
Copy of original
pages for snapshotonly when a page is changed
(Copy-on-write)
SparseFile
Pages
Source
Snapshot
-
7/27/2019 Db Mirroring
45/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved 4545
0404SQL Server 2008
SQLServer
AdventureWork
s DB
SnapshotAdventureWork
s DB
Source Data
Pages
System Catalog
of changed pages
Sparse
FilePages
SELECT ..data.
FROM AdventureWorks
SNAPSHOT
Snapshot
Users
Transactional
-
7/27/2019 Db Mirroring
46/56
0505
SQL Server 2008
SQLServer
AdventureWork
s DB
SnapshotAdventureWork
s DB
Data
Pages
System Catalog
of changed pages Copy of originalpages for snapshot use
only when a page is changed(Copy-on-write)
SparseFile
Pages
Transactional
Users
translog
UpdateRowA
B
B
B
B
C
Committed
-
7/27/2019 Db Mirroring
47/56
0606SQL Server 2008
AdventureWorks
DB
translog
Source
Server
DatabaseSnapshot
AllUse
rs
DatabaseSnapshot
DatabaseSnapshot
6:00AM Snapshot
12:00PM Snapshot
6:00PM SnapshotRestore from
Any Point-in-timeSnapshot if neededDatabaseSnapshot
12:00AM Snapshot
UPDATE AWSource.tableXset xyz =
FROM AWSnapshot6:00AM.tableX
-
7/27/2019 Db Mirroring
48/56
0707SQL Server 2008
AdventureWorks
DB
Source
Server
DatabaseSnapshot
Users
SAFEGUARD Snapshot(Before the mass changes)
Restore from snapshot
(if changes are not correct)
Generating
Mass Changes
UPDATE AWSource.tableXset xyz =
FROM AWSafegaurd6:00AM.tableX
-
7/27/2019 Db Mirroring
49/56
0808SQL Server 2008
AdventureWorks
DB
Source
Server
DatabaseSnapshot
Te
stingUsers
BEFORE TEST Snapshot
Restore from the BEFORE snapshot
after testing cycle is complete and can
continue with next test.
Trans
-
7/27/2019 Db Mirroring
50/56
0909SQL Server 2008
AdventureWorks
DB
translog
Source
Server
DatabaseSnapshot
nsactional
Use
rs
DatabaseSnapshot
DatabaseSnapshot
6:00AM Reporting Snapshot
12:00PM Reporting Snapshot
6:00PM Reporting Snapshot
DatabaseSnapshot
12:00AM Reporting Snapshot
Point-in-tim
e
Reporting
Users
(Read-Only)
-
7/27/2019 Db Mirroring
51/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved 5151
1010
MSDB DB
SQL Server 2008
SQL Server 2008
Witness
Server
AdventureWorks
DB
SQL Server 2008
Mirror Server
translog
Principal
Server
Netw
ork
Netw
ork
DatabaseSnapshot
Reporti
ngUse
rs
AdventureWorks
DB
translog
DatabaseSnapshot
Ifthisserverno
de
becomesthemirror.
Instance: SQL2008xyz
Endpoint Name: endpoint4mirroring
-
7/27/2019 Db Mirroring
52/56
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
Principal
Server
translog
Adventure
Works DB
Instance: SQL2008zzz
Endpoint Name: endpoint4mirroring
Endpoint Name: endpoint4mirroring
Role: PARTNER
Role: PARTNER
PH
Topology
SQL Server 2008
Principal
Server
Active
Passive
Clustered
OLTPApplication
Replic
ation
NetworkNetwork
Reporting Users
DatabaseSnapshot
DB Mirror andDB Mirror andPublisher
-
7/27/2019 Db Mirroring
53/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved 5353
DB Mirror andDB Mirror and
ReplicationReplicationSQL Server 2008
Principal
Server
SQL Server 2008
Mirror
Server
SQL Server 2008
WitnessServer
SQL Server 2008
Principal
Server
SQL Server 2008
Mirror
Server
SQL Server 2008
Subscriber
SQL Server 2008
Subscriber
Distributor
-
7/27/2019 Db Mirroring
54/56
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/stable
1server/site
1 OLTPsite
Each site onlyneeds regionaldata
Central Publisher
Transactional repl
filter by region
REPLICATION
Read Only
Reportinglong high many low
fast/
stable
1
server/site1 OLTP
site
Each site onlyneeds regionaldata
Central PublisherSnapshot repl
filter by region
Read MostlyA few updates short high < 10 medium
fast/stable
1server/site
1 OLTPsite
Regional updateson one table
Central Publisher
Transactional repl
Updating Subs
Read Mostly
A few updatesmedium high < 10 medium
slow/
unreliab
1
server/site
All
update
Regional updateall tables
Central Publisher
Merge repl
Inserts
(new orders) short high many highfast/stable
1server/site
1
reportsite
Each site only
needs regionaldata
Central Subscriber
Transactional repl
Hot/WarmSpare
Veryshort
high < 2 highfast/stable
1server/site
1 OLTPsite
Fail-overCentral PublisherRemote Distributor
Transactional repl
Read equalEqual updates short high < 10 medium
fast/stable
1server/site
Allupdate
Regional updateall tables
Peer-to-Peer
Transactional
repl
Database Mirroring
Database Mirroring
Database Mirroring
-
7/27/2019 Db Mirroring
55/56
Copyright 2009 all rights reservedCopyright 2009 all rights reserved
QuestionsQuestionsIs there any time left????
Send your questions to:[email protected]
-
7/27/2019 Db Mirroring
56/56