Database Mirroring with SQL Server (An Overview)
About me Matt Denton Worked with SQL Server since version 6.5 Matt.Denton@comcast.net Worked with SQL Server since version 6.5 Worn many hats DBA Developer Architect Tended to focus on Dev vs Admin Currently working at SouthwestRe
Why Database Mirroring? High Availability Disaster Recovery (with asynchronous mode) Generally cheaper than clustering Relatively easy to configure Supported from Version 2005 thru ? At least through version 2016 Often deployable to existing hardware
Database Mirroring Shortcomings Objects external to mirrored database are not synchronized Logins, Operators, Jobs, Linked Servers, windows shares, etc System databases cannot participate Only 1 mirror (target) can exist per principal database Log Shipping, Avail Groups allow multiples targets Mirrored database is not accessible Failover can be a challenge for legacy applications
How does it work? Principal server serves database to clients Mirror Server acts as hot or warm standby All transactions on principal are “redone” to mirror Transactions streamed from principal to mirror Works at level of physical log record (Replication works at logical level) Stream compressed starting with Version 2008 If using Witness in High-Safety mode, mirror server is brought up as principal automatically
How does it work?
Operating Modes High Safety (synchronous) Transactions sync’d immediately on mirror Transactions not committed on principal until committed on mirror Most often used for High Availability High Performance (asynchronous) Transactions sent to mirror asynchronously Transactions committed on principal immediately (no waiting on mirror) Requires Enterprise Edition Most often used for DR
Prerequisites All servers must be on same version of SQL Server Principal/Mirror must be on same edition Witness can be on any edition (including Express, as long as same version)
DEMO
Resources msdn.microsoft.com Search for “Database Mirroring” Google You’ll find more resources and examples than you would ever need Me Feel free to email me with questions (Matt.Denton@comcast.net)