Overview of high availability in Microsoft SQL Server
-
Upload
hall-sharpe -
Category
Documents
-
view
44 -
download
0
description
Transcript of Overview of high availability in Microsoft SQL Server
![Page 1: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/1.jpg)
Overview of high availability in Microsoft SQL Server
Szymon Wójcik
![Page 2: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/2.jpg)
Agenda
IntroductionWhat is availability?What is and why to choose high availability?Key factors to consider for high availability scenarioHigh availability techniques in Microsoft SQL Server
ReplicationLog shippingMirroringFailover clustering
Discussion
![Page 3: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/3.jpg)
PLSSUG Cracow Partners
![Page 4: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/4.jpg)
Agenda
IntroductionWhat is availability?What is and why to choose high availability?Key factors to consider for high availability scenarioHigh availability techniques in Microsoft SQL Server
ReplicationLog shippingMirroringFailover clustering
Discussion
![Page 5: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/5.jpg)
Introduction
Szymon WójcikExperience with MS SQL Server since 2000 (dev/admin)MCITP: DBA SQL Server 2005Interests:
Performance tuningHigh availability
Blog – sqlphobosq.wordpress.comTwitter - @phobosq
![Page 6: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/6.jpg)
Agenda
IntroductionWhat is availability?What is and why to choose high availability?Key factors to consider for high availability scenarioHigh availability techniques in Microsoft SQL Server
ReplicationLog shippingMirroringFailover clustering
Discussion
![Page 7: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/7.jpg)
Availability [1/5]
One of the concepts defined within ITILAbility to perform its agreed function when requiredDetermined by:
Reliability – how long (MTBF)Maintainability – how quickly restored (MTRS)Serviceability – contract conditionsPerformanceSecurity
ConfidentialityIntegrityAvailability
![Page 8: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/8.jpg)
Availability [2/5]
Best practice – measure in %:
Agreed Service Time – defined in SLA (Service Level Agreement)Downtime – duration of service unavailability during Agreed Service TimeImportant when planning/deploying a service to understand availability concept
![Page 9: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/9.jpg)
Availability [3/5] – figures for one week
Allowed downtime duration per week [hh:mm:ss format]Availability level 8x5 (40 hours/week) 24x7 (168 hours/week)
80% 08:00:00 33:36:00
90% 04:00:00 16:48:00
95% 02:00:00 08:24:00
98% 00:48:00 03:21:36
99% 00:24:00 01:40:48
99,9% 00:02:24 00:10:05
99,99% 00:00:14,4 00:01:01
99,999% 00:00:01,44 00:00:06
![Page 10: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/10.jpg)
Availability [4/5] – figures for one year
Allowed downtime duration per year [DD.hh:mm:ss format]Availability level 8x5 (40 hours/week) 24x7 (168 hours/week)
80% 52.00:00:00 73.00:00:00
90% 26.00:00:00 36.12:00:00
95% 13.00:00:00 18.06:00:00
98% 5.04:48:00 7.07:24:00
99% 2.14:24:00 3.15:48:00
99,9% 0.06:14:24 0.08:45:36
99,99% 0.00:37:26 0.00:52:33
99,999% 0.00:03:45 0.00:05:15
![Page 11: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/11.jpg)
Availability [5/5] – important notes
Availability != Uptime (service may be up but unavailable)Scheduled downtime does not have to cause unavailability (up to definition in SLA)
![Page 12: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/12.jpg)
Agenda
IntroductionWhat is availability?What is and why to choose high availability?Key factors to consider for high availability scenarioHigh availability techniques in Microsoft SQL Server
ReplicationLog shippingMirroringFailover clustering
Discussion
![Page 13: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/13.jpg)
High availability - definition
System design approach and service implementation that ensures a certain level of operational performance (Wikipedia)Masks the effects of hardware or software failureMaintains availability of applications so that perceived downtime is minimized (Microsoft)
![Page 14: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/14.jpg)
High availability != disaster recovery
High availability is used for ensuring for meeting Service Level Target for availabilityDisaster recovery is ensuring operational continuityThey can be used complementary – HA can minimize the need of invoking DR, but never replace it
![Page 15: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/15.jpg)
Why to choose high availability
For users:Minimizes downtime probabilityAllows to sustain a failure if properly designed
For administrators:Simplifies migration effortMinimizes risk of continuity
![Page 16: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/16.jpg)
Agenda
IntroductionWhat is availability?What is and why to choose high availability?Key factors to consider for high availability scenarioHigh availability techniques in Microsoft SQL Server
ReplicationLog shippingMirroringFailover clustering
Discussion
![Page 17: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/17.jpg)
Single point of failure
A whole system is as strong as the weakest link
User
Server
LAN
Switch
Router
Server on the Web
![Page 18: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/18.jpg)
Hardware redundancy
Introduce additional hardware to minimize risk of failure
User
Server
LAN
Switch
Router
Server on the Web
Switch
Router
![Page 19: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/19.jpg)
Hardware redundancy
Not only whole machines may be multiplicated to become fault tolerantAlso components:
Power suppliesCPUsHard disksNetwork interface cardsStorage controllers
![Page 20: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/20.jpg)
Standby node
A standby node is a machine in a HA system that takes over in case of primary server failureThree types:
Cold standby – Unplugged, needs to be prepared before useWarm standby – Ready to use, but requires manual switchHot standby – Ready to use, takes over automatically
Fail over = switching from primary to standbyFail back = return to primary
There may be more than one standby in HA scenario!
![Page 21: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/21.jpg)
Load balancing vs failover
Load balancing – distributing of workload between several peer servers
If one goes down, others take overWorkload distributed by load balancer
Failover – automatic switch to standbyStandby is not activeSwitch initiated upon loss of heartbeat
![Page 22: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/22.jpg)
Other points
High availability requires additional costs – multiple components must be present according to design in order to meet requirementsIt may become complex to maintain – additional CIs present in environment that need to be kept up-to-dateHardware design must be followed by software to fully benefit from HAKISS – Keep It Simple and Stupid
![Page 23: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/23.jpg)
Agenda
IntroductionWhat is availability?What is and why to choose high availability?Key factors to consider for high availability scenarioHigh availability techniques in Microsoft SQL Server
ReplicationLog shippingMirroringFailover clustering
Discussion
![Page 24: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/24.jpg)
High availability in Microsoft SQL Server
SQL Server, as a RDBMS, provides means for failover scenarioLoad balancing is difficult and must be properly designed in order to workHigh availability in SQL Server does not prevent logical data corruption – periodic DBCC checks are advised
![Page 25: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/25.jpg)
HA methods overview in SQL ServerMethod What it does Standby
type# of standby
nodesRemark
ReplicationTransfers completed transactions to standby nodes
Cold/warm Any• Standby is accessible• May allow for updates• Conflicts may appear
Log shippingPerforms regular log backups, copy to standby and restore
Cold Any• Database unavailable
during restore• Standby may be
accessible
Database mirroring
Replays transactions as they are logged Warm/hot 1
• Standby unavailable• Requires third server
to allow hot standby
Failover cluster
Monitors Windows service status and transfers execution
Hot Any
• Requires shared (or replicated) storage
• Requires identical hardware
• Failover = downtime
![Page 26: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/26.jpg)
Replication
Three server roles in replication:PublisherDistributorSubscriber
Three types:SnapshotTransactionalMerge
Two subscription methods:Push – Distributor pushes articles to SubscribersPull – Subscribers downloads from Distributor
![Page 27: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/27.jpg)
Replication topology
Publisher
Distributor
Subscriber
Publisher
Subscriber
Subscriber
Subscriber
![Page 28: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/28.jpg)
Possible application of replication
Create a second copy of data to be used in case of emergency (DR)Create a copy of data to offload the server (load balancing)Allow offline users to work with data and upload their changes later (high availability)
![Page 29: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/29.jpg)
Replication agents
External programs which are used to implement replication:
Snapshot Agent:creates snapshots
Log Reader Agent:Reads transaction logMarks transactions for replication
Distribution Agent:Dispatches transactions to Subscriber
Merge Agent:Downloads remote and uploads local changesResolves conflicts in merge replication
![Page 30: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/30.jpg)
Snapshot replication
Publisher makes a copy of a database which is applied at SubscriberGood for small, static data:
Whole snapshot is applied every time – the changes which appear after snapshot will be applied with next snapshotRequires sufficient bandwidth
![Page 31: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/31.jpg)
Transactional replication
Starts with a snapshotTransactions are recorded at Publisher and replayed at SubscriberMay allow for updatable subcriptionsIf Subscriber is offline, records are stored at the Distributor
![Page 32: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/32.jpg)
Merge replication
Starts with a snapshotMerges changes between Publisher and SubscribersAllows synchronization via HTTPS (since SQL Server 2008)Allows the most autonomous design – e.g. mobile users, multiple branch offices working on the same data
![Page 33: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/33.jpg)
Replication how-to
Configure DistributorConfigure Publisher:
Select replication typeSelect articles to be published[Optional] Set up article filteringSet up security
Configure Subscribers:Connect to DistributorSelect subscription method
Apply snapshot[Transactional/merge] Synchronize changes
![Page 34: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/34.jpg)
Failover in replication
Stop subscriptionDirect all traffic from Publisher to Subscriber:
Change application connection stringsChange DNS aliases, if required, orChange IP addresses
![Page 35: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/35.jpg)
Failback in replication
After restoring Publisher, restore a copy of database from SubscriberDirect all traffic from Subscriber to PublisherReestablish the replication
![Page 36: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/36.jpg)
Log shipping
Keeps a standby by automating backup, copy and restore processThree server roles in log shipping:
PrimarySecondaryMonitor
![Page 37: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/37.jpg)
How it works? [1/2]
Restore a full backup from Primary to Secondary and then:
A job runs on Primary which backs up transaction logSecond job copies the log backup to SecondaryThird job on Secondary restores the log after it’s copied
[Optional] Monitor server tracks performance and incidents
![Page 38: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/38.jpg)
How it works? [2/2]
Primary Secondary
Monitor
![Page 39: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/39.jpg)
Failover in log shipping
Copy transaction log backups from primary to secondaryBackup tail of the log on primaryRestore all backups except tail-log with NORECOVERYRestore tail-log with RECOVERYDisable log shipping jobsRedirect client traffic to secondary
![Page 40: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/40.jpg)
Drawbacks of log shipping
You can’t miss a transaction log backupNetwork traffic generated has to be consideredYou are always behind on SecondarySecondary is read-only
![Page 41: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/41.jpg)
Database mirroring
Allows to keep your standby up-to-dateAllows automatic failoverCost-effective alternative to clusteringAvailable in Standard Edition (2005 – 2008 R2)Does not require cluster capable hardwareMight be in implemented when Windows Authentication mode is not possible (using certificates)
![Page 42: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/42.jpg)
How it works?
Principal Mirror
Witness
![Page 43: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/43.jpg)
Database mirroring modes
High availability (with witness)Automatic failoverSynchronous transaction commit (principal commits after mirror confirms it’s commit)
High protection (without witness)Manual failoverSynchronous transaction commit
High performance (without witness)Manual failoverAsynchronous transaction commit
![Page 44: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/44.jpg)
Manual failover in database mirroring
Can be done with one mouse click in SSMSRequires client traffic redirection:
Possible within connection string using Failover Partner command
![Page 45: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/45.jpg)
Automatic failover in database mirroring
Initiated automatically by witness if there is no quorum:
If principal is unavailable, fails over to mirrorDoes nothing if mirror becomes unavailableFails over also if principal is up but unreachable from network!
Requires client traffic redirection:Possible within connection string using Failover Partner command
![Page 46: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/46.jpg)
Failover clustering
Provides protection on a server level:Automatic failover in case of server failureFails over logins, endpoints and jobs
Combines multiple machines (nodes) in a single virtual serverRequires cluster-capable hardware:
Shared or common storageCertified server hardware
![Page 47: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/47.jpg)
Clustering
Node A
Node B
UserStorage
Cluster
![Page 48: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/48.jpg)
Failover in a cluster
Node A
Node B
UserStorage
Cluster
Node A
Node B
UserStorage
Cluster
Node A
Node B
UserStorage
Cluster
![Page 49: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/49.jpg)
SummaryMethod What it does Standby
type# of standby
nodesRemark
ReplicationTransfers completed transactions to standby nodes
Cold/warm Any• Standby is accessible• May allow for updates• Conflicts may appear
Log shippingPerforms regular log backups, copy to standby and restore
Cold Any• Database unavailable
during restore• Standby may be
accessible
Database mirroring
Replays transactions as they are logged Warm/hot 1
• Standby unavailable• Requires third server
to allow hot standby
Failover cluster
Monitors Windows service status and transfers execution
Hot Any
• Requires shared (or replicated) storage
• Requires identical hardware
• Failover = downtime
![Page 50: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/50.jpg)
Discussion
![Page 51: Overview of high availability in Microsoft SQL Server](https://reader035.fdocuments.us/reader035/viewer/2022062422/56813751550346895d9ee402/html5/thumbnails/51.jpg)
THANK YOU!