SQL SATURDAY # 91 - OMAHA HIGH-AVAILABILITY & D/R OPTIONS FOR MICROSOFT SQL SERVER 8/27/11 Tim Plas, Virteva tim.plas@virteva.com 1
The Presenter Tim Plas, Principal Consultant at Virteva (Mpls) Operational DBA: Keep SQL servers running & optimized for managed-services clients My other current specialties: Storage, Cloud services, Server virtualization 25+ years in IT, in many roles Mostly servers / infrastructure in last 15 years Multiple MS certs starting in 1994 2
The Agenda SQL HA & DR -- HIGH AVAILABILITY & DISASTER RECOVERY Based on the experiences of having installed & managed all current varieties of SQL HA & DR MATERIAL TO BE COVERED: Microsoft licensing for SQL HA & DR What kind of differences are there in HA & DR options? Summary list of the HA & DR Approaches HA & DR approaches, one by one What are the trade-offs? Which approach do I recommend for a given scenario? SQL Denali AlwaysON (HA / DR) overview 3
Microsoft Licensing for SQL HA & DR Typical usage is Active / Passive Active node must have SQL Server license Passive node does not need SQL license As long as no one is accessing database services on the secondary server while primary server is active. Need to move back within 30 days Still need Windows server license if using 2 servers Some approaches need Enterprise vs. Standard Edition (of Windows and/or SQL Server) 4
Distinguishing Criteria for HA & DR Options Does it keep more than one copy of the data? Is the approach better suited for HA or DR? Does it protect the whole SQL Server instance, or just individual database(s)? Are you running one or two SQL server instances? How quickly can clients get back online? How do clients get re-connected & how do they find the current primary server? There WILL be a re-connect (i.e., down-time) during the switch! -with any approach Does it mostly need SQL DBA skills or Windows sysadmin skills? --or something else? 5
The Approaches to SQL HA & DR Microsoft Clustering ( MSCS / Failover Clustering) Log-shipping Database Mirroring (since SQL 2005) SQL Replication (transactional replication) 3 rd -party software (DoubleTake, etc.) Virtualization-based SAN replication 6
HA/DR Approach # 1 MS CLUSTERING FOR SQL SERVER 7
Why I didn t formerly like MS clustering Expensive; Exotic hardware High-end people skills High complexity ( = more likely to break ) Single copy of data 8
Why I like MS clustering now (Windows Server 2008, with SQL 2008) ( R2 made it even better) Affordable; Easily achievable Much simpler now But Still single copy of data 9
MS Clustering for SQL The Basics Two (or more) servers, running Windows Server Enterprise Edition (Win2008) Must have some form of shared disk Configure cluster services (Windows role) Wizard-driven, but does require some pre-planning Need to assign virtual server name(s) & IP(s) You end up with Win server A, Win server B, SQL server X Need to assign disk volumes for cluster to manage (disk volumes belong to one server at a time) Install SQL Server as cluster nodes (SQL2008) 10
MS Clustering Characteristics Licensing = 2 x Win EE + 1 SQL (SE or EE) Single copy of the data Protects entire SQL instance, not specific DB(s) Single SQL instance running; no client-side issues Automatic fail-over, and decent re-connect time Restarts SQL instance on other node Requires some extra Windows admin skills; little additional for DBA Mostly HA approach; not really DR 11
MS Clustering with SQL Server DB Win Server A SQL Services Win Server B SQL Services SQL Instance Client 12
HA/DR Approach # 2 LOG SHIPPING 13
Log-Shipping The Basics Two SQL servers: One is active, and other is warm-standby Primary server performs frequent tran-log backups, & sends them to secondary Secondary copy of DB is always in restoring mode, until it s needed to stand in --Then you have to put it into normal DB mode, & get everybody to point to it Has been fairly common design 14
Log-Shipping Characteristics Licensing = 2 x Win + 1 x SQL Maintains replicated copy of the data Protects individual DB(s), not whole SQL instance Two SQL instances to deal with Some assembly required by DBA Simple Windows admin; some DBA complexity Fail-over requires special handling; Warm standby is probably best description Great for maintaining off-site D/R replica of DB 15
HA/DR Approach # 3 DATABASE MIRRORING 16
Database Mirroring The Basics New with SQL 2005; improved with SQL 2008 Resembles an automated version of Log-Shipping But transactions go continuously to DB, not via series of backup/restore jobs Two SQL servers: Active / Passive Principal + Mirror roles, in MS terminology + optional Witness (if doing auto-failover) Witness can be SQL Express; it s not serving any DB Super-simple to set up 17
18 SQL HA/DR with Mirroring
DB-Mirroring Characteristics Very simple to set up (too simple?) Licensing = 2 x Win + 1 x SQL (EE for some options) Maintains replicated copy of the data Protects individual DB(s), not whole SQL instance Limited on # of DB s simultaneously mirrored Two SQL instances to deal with Automatic fail-over, and VERY fast 2 nd server already running, w/ fully-sync ed DB [cont d] 19
DB-Mirroring Characteristics [cont d] Clients need special connection to find active node SNAC SQL Native Access Client Some assembly required by DBA, at least for auto failover To sync objects between servers Data replication portion is very automatic Can t access secondary, except via snapshots Simple Windows admin; some DBA complexity Best for HA; possible use for DR 20
Database Mirroring Two Options Synchronous vs. Async = * High Safety vs. High Performance = Standard vs. Enterprise ------------------------------------------------------------- * or High Availability with witness server 21
HA/DR Approach # 4 TRANSACTIONAL REPLICATION 22
Transactional Replication The Basics Multiple varieties of SQL replication exist: Transactional can be used for a near-real-time DB replica Somewhat similar to log-shipping, except: Data flows directly to DB; not thru backup / restore THE BIGGIE: Replica DB is accessible by others Requires special characteristics in the DB 23
Transactional Replication Characteristics Licensing = 2 x Win + TWO x SQL Replicated copy of the data; can access 2 nd copy Protects individual DB(s), not whole SQL instance Replicates only data in tables, not other objects Not great for fail-over; certainly not auto Sometimes combined with other HA or DR methods; Allows usage of dup hardware for reporting Definitely need SQL DBA skills (requires pri. keys) 24
HA/DR Approach # 5 3 rd -PARTY SQL HA/DR TOOLS 25
3 rd -Party SQL HA/DR Tools The Basics Two servers, running proprietary software agents (source + target) Software maintains a replica of data onto second server, and provides failover capability when primary goes down Secondary server assumes identity of primary during fail-over IP address, server name, etc. Has additional possibilities, such as many-to-one coverage, geo-clustering 26
3 rd -Party SQL HA/DR Tools Characteristics Licensing = 2 x Win + 1 SQL + software license Replicated copy of the data Protects entire SQL instance, not individual DB(s) Single SQL instance running No client-side issues Automatic fail-over (starts up SQL on 2 nd server); Have seen messy fail-back situations Moderate Windows sys-admin skills; simple for DBA; some add l knowledge for 3 rd -party solution Adds additional complexity 27
HA/DR Approach # 6 SQL HA/DR BASED ON VIRTUALIZATION 28
SQL HA/DR with Virtualization The Basics Can run any of preceeding SQL HA/DR options in virtualized form Virtualization vendors offer HA / cluster solutions that protect any type of server SQL Server A running as guest on server-1; Server-1 fails, so server-2 picks up disks from SQL Server A and boots it up (Assumes shared storage) Also possible with replicated disk, e.g. at D/R site 29
Virtualization HA/DR Characteristics Licensing = ONE x Win + 1 SQL + maybe software Data may or may not be replicated, depending on chosen approach Protects entire SQL instance, not individual DB(s) Single SQL instance running at one time No client-side issues Automatic fail-over, and decent re-connect time Server reboot time Simple Windows sys-admin skills; simple for DBA; some additional knowledge for virtualization and storage 30
SQL HA/DR Approaches SUMMARIZING / COMPARING OPTIONS 31
What trade-offs need to be considered? It all depends Which costs are most important: Hardware, Licensing of Windows / SQL / software, Initial setup, On-going maint, Skill sets, Downtime Safety of data: Replicated copy or single copy? Requirements for continuous availability Is replicated data good enough? How fast failover needed? Complexity: Per-DB or whole instance, Reconnect method, How many clients 32
Comparing SQL HA/DR Options MSCS Log-Ship DB Mirror Tran.Repl. 3 rd -Party Virtual Replicated data? N Y Y Y Y Y/N Licensing Protect DB / Instance 1 SQL 2 WinEE 1 SQL 2 Win 1 SQL 2 Win 2 SQL 2 Win 1 SQL 2 Win + 1 SQL 1 Win Instance DB DB DB Instance Instance # of SQL Servers 1 2 2 2 1 1 Failover Time Minute: Start SQL Minutes to switch Seconds Usually Manual Minute: Start SQL Minutes: Reboot Client Re-connect Easy Messy Easy * Messy Easy Easy Windows Admin Skills Some extra Easy Easy Easy Some extra DBA Admin Skills Easy Complex Moderate Complex Easy Easy Usage Recomm. Solid HA Good for WAN D/R Fast! Simple Good for reporting Not any more Easy Easy HA 33
Recommendations for various scenarios Continuous availability DB mirroring -very fast fail-over MS F-O clustering -perhaps with SAN replication Virtualization HA cluster -very simple Replicated data for warm stand-by, e.g. off-site DB mirroring -simple setup (but EE license) Log shipping -some assembly required Transactional replication -if want reporting copy SAN replication Hybrids, especially with reporting 34
SQL Denali AlwaysOn Availability Groups Clustering AND Mirroring, wrapped together Can still do traditional clustering & mirroring (at least for now), but why would you? Fixes clustering issues: Single-site; Shared storage; Single copy of database Fixes mirroring issues: Multiple DB s together; Able to access 2 nd copy; > 1 replica Can use for both HA and DR 35
SQL Denali Availability Groups A set of DB s that failover together Can have multiple FO targets (mult. secondary replicas --up to 4 --vs. current 1 mirror) Secondary replicas can allow read access: Backups, reporting Can be async-commit or sync-commit (or both, if > 1 replica) Good tools Fast failover, with flexible FO policies 36
SQL Denali HA / DR My biggest fear: Licensing Which features will be available in which SKU s / Editions? Keep in mind: Not all of current mirroring functionality is available in Standard Edition Licensing for 2 nd system is sure to be required if it s not just active/passive -- and that s fair My opinion: If you can afford Enterprise, then AlwaysOn Availability Groups will be the way to achieve HA and DR If you can t afford it, or can t wait, then traditional HA/DR tools are required 37
SQL HA & DR Options Questions? -Tim Plas, Virteva tim.plas@virteva.com 952-843-1148 42