Introduction to High Availability with SQL Server

Post on 14-Dec-2014

198 views 5 download

Tags:

description

Have you ever wondered how companies keep their databases online through unplanned disasters? Have you wondered which high availability features might be best for our shop? In this session we will go over a quick look at log shipping, database mirroring, transactional replication, failover cluster instances and availability groups. John will identify pros and cons for each features and share some tips from the field.

transcript

04/10/2023 www.linchpinpeople.com 1

Introduction to High Availability with SQL Server

www.linchpinpeople.com 2

John Sterrett

@johnsterrettJohn.Sterrett@linchpinpeople.comJohnsterrett.comlinked.com/in/johnsterrettgoogle.com/+johnsterrett

Specialties / Focus Areas / Passions:

• Performance Tuning & Troubleshooting

• Virtualization• Infrastructure• Architecture

• High Availability• Disaster Recovery• Health Monitoring• Capacity Management• License Efficiency

Linchpin People Group Principle

Leader Austin SQL Server User Group Leader Virtual Chapter “High Availability and Disaster Recovery”PASS Regional Mentor

www.linchpinpeople.com 3

Linchpin People® are database coaches and wellness experts for the Microsoft SQL Server Ecosystem. Our team includes more than 15 of the world’s top SQL Server experts, and we have presented over 175 combined sessions at SQL Saturdays, PASS Summit, and other events in the past year.

Do you have specific questions about your database environment? Check out www.LinchpinPeople.com and take a look at the range of services we provide, or contact one of us today to learn how we can help improve your business.

You know us individually, but do you know Linchpin People®?

04/10/2023 www.linchpinpeople.com 4

Agenda• HA != DR

• Log Shipping

• Database Mirroring

• Transactional Replication

• AlwaysOn Failover Cluster Instance

• AlwaysOn Availability Groups

• Wrap Up / Question and Answer

04/10/2023 www.linchpinpeople.com 5

Introduction

Definitions

•What do we mean when we say a system is Highly Available?

•What does it mean to have a Disaster Recovery system?

04/10/2023 www.linchpinpeople.com 6

High Availability

What is High Availability• High availability is a system design approach and

associated service implementation that ensures a prearranged level of operational performance will be met during a contractual measurement period. –Wikipedia

• A System Design that allows for minimal downtime.• Protection from OS or hardware failure

04/10/2023 www.linchpinpeople.com 7

Examples of Disasters

Photo https://www.flickr.com/photos/ross/39556863/

04/10/2023 www.linchpinpeople.com 8

Most Common Disaster

04/10/2023 www.linchpinpeople.com 9

Disaster Recovery

What is Disaster Recovery•Risk Management•Recovery Point Objective - RPO•Recovery Time Objective - RTO•Disaster Recovery Plan - DRP

•Backups are not enough

04/10/2023 www.linchpinpeople.com 10

Options

SQL Server Options for HA/DR

•Log Shipping•Database Mirroring•Replication•Failover Cluster Instances•AlwaysOn Availability Groups

04/10/2023 www.linchpinpeople.com 11

Intro to Log Shipping

1. Transactional Log Backup

2. Copy Transactional log backups3. Restore Transactional log

backups

http://www.mssqltips.com/sqlservertip/2073/migrating-a-vldb-in-sql-server-with-log-shipping/

04/10/2023 www.linchpinpeople.com 12

04/10/2023 www.linchpinpeople.com 13

Log Shipping

•Transaction Log backups occur on the primary•Process ships logs to secondary server(s)•Data can be read on the secondary except

during transaction log restore•Can have a Log Ship monitor server

04/10/2023 www.linchpinpeople.com 14

Monitoring Log Shipping

• sp_help_log_shipping_monitor

04/10/2023 www.linchpinpeople.com 15

Log Shipping Pros/Cons•Works with Standard Edition•Multiple target support•Readable secondary copies •Can delay restores

•Dependent on backup of primary

•Manual failover process•Reasonably high complexity

04/10/2023 www.linchpinpeople.com 16

Database Mirroring - Modes• High Safety (Synchronous) with Automatic Failover• High Safety without Automatic Failover• High Performance (Asynchronous)

Primary Server Secondary Server

WitnessInstance

MirrorDB

Mirror DB

04/10/2023 www.linchpinpeople.com 17

Synchronous Mode…

Mode

Principal • Transaction (Insert/Update/Delete) inserted into Transactional Log

• Transaction read from the transactional log• Transaction shipped to mirror

Mirror • Transaction written to mirrors transactional log• Acknowledgement sent to principal• Transaction committed

Principal • Acknowledgement received• Transaction committed.

04/10/2023 www.linchpinpeople.com 18

Asynchronous Mode… (Enterprise)Mode

Principal • Transaction (Insert/Update/Delete) inserted into Transactional Log

• Transaction read from the transactional log• Transaction committed• Transaction shipped to mirror

Mirror • Transaction written to mirrors transactional log• Acknowledgement sent to principal• Transaction committed

Principal • Acknowledgement received

04/10/2023 www.linchpinpeople.com 19

Database Mirroring

•Deprecated in SQL 2012•Database transactions are compressed and

shipped to a secondary (2008+)•Transfer may be sync or async (Enterprise)•Optional witness server can facilitate failover

Warning.. Warning.. Warning..

http://technet.microsoft.com/en-us/library/ms366349.aspx

04/10/2023 www.linchpinpeople.com 21

Pros and Cons

• Pros• Witness can be any edition of SQL Server• Page level corruption fixes• Doesn’t require Active Directory• Database level High Availability• High Safety only requires Standard Edition

• Cons• You cannot mirror system databases• Automatic Failover requires a witness• Database must be in full recovery• High Performance requires Enterprise Edition• Must create and sync Instance Objects (Jobs, Logins, etc..)

04/10/2023 www.linchpinpeople.com 22

Replication

•Numerous topologies and options involved with replication

•Snapshot Replication•Transactional Replication•Merge Replication•Peer to Peer Replication

04/10/2023 www.linchpinpeople.com 23

How Transactional Replication Works

http://technet.microsoft.com/en-us/library/ms151706(v=sql.105).aspx

04/10/2023 www.linchpinpeople.com 25

Replication Pros/Cons•Replicate to multiple servers•Replicate subset of data•Can be done with Simple Recovery Model•Standard Edition for transactional

•Manual failover process•Unknown RPO•Known to be fragile•Re-sync can be cumbersome•Complex

04/10/2023 www.linchpinpeople.com 26

Failover Cluster Instances

SQL Instance

Node 1 Node 2

Windows Failover Cluster

Cluster Virtual Name

27

How Windows - SQL Clustering works• Physical Nodes

• Windows cluster• Windows cluster group• MSDTC• SQL cluster• Other clustered application

• End User Access

04/10/2023 www.linchpinpeople.com 28

Failover Cluster Instance (FCI)

•Pre Windows 2012 – Shared Storage•Windows Cluster (Windows 2012 Standard Ed)•Two Node Limit on SQL 2012 Standard•Quorum

29

How Window – SQL Clustering Works – Failover Cluster ManagerThings that you should see in Service and Application/ Role

• Current Status

• Current Owner

• Resources• Client Access Point

• Virtual Network Name• IP address assigned with the name

• Storage allocated to the application• Services / Applications or Predefined

Resources• Others - optional

• File shares• Printers and so on

04/10/2023 www.linchpinpeople.com 30

Quorum

04/10/2023 www.linchpinpeople.com 31

04/10/2023 www.linchpinpeople.com 32

04/10/2023 www.linchpinpeople.com 33

04/10/2023 www.linchpinpeople.com 34

04/10/2023 www.linchpinpeople.com 35

Failover Cluster Pros/Cons•Multiple Servers (HA)•Allows for entire instance

protection•Automatic failover•Transparent connections

•Complex setup• Idle hardware•Some cases storage single

point of failure

04/10/2023 www.linchpinpeople.com 36

Introduction to Availability Groups

Node 1 Node 2

Instance 1

Instance 2

AG (P) AG (S)

Data Center 1 Data Center 2

Windows Failover Cluster

Listner Name (VCO)

04/10/2023 www.linchpinpeople.com 37

Database Mirroring Problems…• Cannot group databases• Only get one mirror database• No readable copies• Requires witness (extra SQL instance) for automatic

failover

04/10/2023 www.linchpinpeople.com 38

Availability Group Benefits..• No shared storage• Listener (Virtual Computer Object for connectivity)• Multiple mirrors replicas• Readable copies

04/10/2023 www.linchpinpeople.com 39

AlwaysOn Availability Groups

•SQL Server Enterprise Edition•Windows Cluster •Async and Sync modes•Databases failover as a group•No shared storage needed•Readable replicas•Supports up to 8 replicas

Requires Downtime

04/10/2023 www.linchpinpeople.com 41

04/10/2023 www.linchpinpeople.com 42

AG Configurations

04/10/2023 www.linchpinpeople.com 43

AG Dashboard

04/10/2023 www.linchpinpeople.com 44

AlwaysOn Pros/Cons•No shared storage•Readable secondaries•SSMS administration•Configuration is easy•Grouping DB failover helps

for complex applications setups

•Enterprise Only - Large setups can be expensive

•Newer technology•App code changes may

be needed

04/10/2023 www.linchpinpeople.com 45

Questions?