26
MIRRORING: START TO FINISH Presentation by Ryan Adams Blog - http://ryanjadams.com Twitter - @ryanjadams Email [email protected]

MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Embed Size (px)

Citation preview

Page 1: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

MIRRORING:

START TO FINISH

Presentation by Ryan Adams

Blog - http://ryanjadams.com

Twitter - @ryanjadams

Email – [email protected]

Page 2: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Objectives

Define Mirroring

Describe how mirroring fits into HA and DR

Terminology

The Rules

What’s new in 2008 mirroring?

Demo – How to configure mirroring

Other Considerations

Demo - Monitoring Mirroring

DBA 302/303 - Session 4 2

Page 3: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

v

What is mirroring?

Page 4: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

• What is the difference between HA and DR?

• Which business requirement does mirroring

solve?

DBA 302/303 - Session 4 4

Where does Mirroring fit in?

Page 5: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

What are my other HA/DR Options?

• Clustering – HA only until server 2008

• Transactional Replication – HA & DR

• Peer to Peer Replication – HA & DR

• Think Mesh topology or AD replication

• Log Shipping – HA & DR

• Backups - DR

DBA 302/303 - Session 4 5

Page 6: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

v

Terminology

Page 7: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Principal

Mirror

Witness

Endpoint

Session

State – 5 states

Mode – 3 modes

DBA 302/303 - Session 4 7

Terms

Page 8: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Session States

• Synchronizing

• Synchronized

• Suspended

• Pending Failover

• Disconnected

DBA 302/303 - Session 4 8

Page 9: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Modes

• High Safety with Automatic Failover

• High Safety without Automatic Failover

• High Performance

DBA 302/303 - Session 4 9

Page 10: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

v

The Rules

Page 11: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Rules

• You cannot mirror any system DBs

• High Performance requires Enterprise Edition

• Witness can be any edition including workgroup, web, and express

• Automatic failover requires a witness

• DB must be in full recovery mode

• You cannot mirror a DB that uses Filestream

DBA 302/303 - Session 4 1

1

• Maintenance plans do not support mirroring until SQL 2005 SP2 CU10

• Avoid local system for SQL service account

• Database compatibility level must be greater than 90 (SQL 2005)

• Peer to Peer Replication cannot be used in conjunction with mirroring.

Page 12: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

What’s new for mirroring in SQL 2008

DBA 302/303 - Session 4 1

2

• Log Stream Compression 1

• Automatic Page Recovery 2

• Better use of log stream buffers

3

• Additional performance counters

4

Page 13: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

What’s new for mirroring in SQL 2012

DBA 302/303 - Session 4 1

3

Page 14: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

v

How it Works

Page 15: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Synchronous Mode

DBA 302/303 - Session 4 1

5

Principal

• Transaction Inserted in Log

• Transaction Read from Log

• Transaction Shipped to Mirror

Mirror

• Transaction Written to Log

• Acknowledgement Sent to Principal

• Transaction Committed

Principal

• Acknowledgement Received

• Transaction Committed

Page 16: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Asynchronous Mode

DBA 302/303 - Session 4 1

6

Principal

• Transaction Inserted in Log

• Transaction Read from Log

• Transaction Committed

• Transaction Shipped to Mirror

Mirror

• Transaction Written to Log

• Acknowledgement Sent to Principal

• Transaction Committed

Principal • Acknowledgement Received

Page 17: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Configuration Steps

Restore DB and Log Backup on Mirror with no recovery

Create Mirroring Endpoints

Create Logins for SQL Service Account

Grant Connect on Endpoints to Logins

Set Principal Partner on Mirror

Set Mirror Partner on Principal

Set Failover Timeout

DBA 302/303 - Session 4 1

7

Page 18: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

v

Demo

Page 19: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Comparison

DBA 302/303 - Session 4 1

9

Mirroring

• DB replicated to one other instance

• Transactions shipped real time

• Mirror DB not available for queries (Snapshot)

• Data is compressed over the wire

• Automatic page recovery

Log Shipping

• DB replicated to many other instances

• Transactions shipped on a schedule

• Secondary DB available for queries

• Only compressed if log backups are compressed

• No page recovery

Page 20: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

v

Other Considerations

Page 21: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Is Your Mirror Server Prepared?

• Logins

• SQLAgent Jobs

• SSIS Packages

• Linked Servers

• Database Level Options

• Change owner on mirror

• Set Trustworthy option on mirror

• Instance Level Options

• Enable CLR

• Database Mail

• Extended SPs like xp_cmdshell

DBA 302/303 - Session 4 2

1

Page 22: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

v

Monitoring

Page 23: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Mirror Monitoring

Where is the data stored

msdb.dbo.dbm_monitor_data

Performance Counter Root Location

SQLServer:Database Mirroring

MSSQL$InstanceName:Database Mirroring

How to view the data

Database Mirroring Monitor

System Stored Procedures

Sp_dbmmonitorresults

Sp_dbmmonitorchangealert

Sp_dbmmonitorhelpalert

Sp_dbmmonitordropalert

Perfmon

DBA 302/303 - Session 4 2

3

Page 24: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

v

Demo

Page 25: MIRRORING: START TO FINISH - Ryan Adams Blog · MIRRORING: START TO FINISH Presentation by Ryan Adams ... • Pro SQL Server 2008 Mirroring ... • Web – CyberSQL.blogspot.com •

Summary

DBA 302/303 - Session 4 2

5

Mirroring Defined

Business Requirements Defined

Terminology Defined

Rules Defined

Configuration Steps

Monitoring