35
The Magic of Replication What’s new in SQL Server 2008 Replication?

Sqlpass The Magic Of Replication

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Sqlpass   The Magic Of Replication

The Magic of Replication

What’s new in SQL Server 2008 Replication?

Page 2: Sqlpass   The Magic Of Replication

Who Am I?

Meir Dudai• SQL Server consultant – Valinor (SQL Server

Consulting Services)• Working with SQL Server for 10 years• Specialize in Replication, my favorite feature in

SQL Server• Operating SQL Server Israeli website:

http://www.SQLServer.co.il/

[email protected]

Page 3: Sqlpass   The Magic Of Replication

Agenda

• SQL Server’s greatest challenge• Replication overview• Peer-to-Peer Replication • Replication enhancements – SQL Server 2008

Page 4: Sqlpass   The Magic Of Replication

SQL Server’s greatest challenge

Page 5: Sqlpass   The Magic Of Replication

SQL Server’s greatest challenge

• We want availability and scalability!• The database is a

single point of failure

• The database sometimes is the performance bottleneck

Scale UpScale

Out

Page 6: Sqlpass   The Magic Of Replication

A DBA’s dream

• Application/website always online• Workload is distributed amongst many servers

Page 7: Sqlpass   The Magic Of Replication

Scalability and Availability Options in SQL Server

•Copy unreadableDatabase Mirroring

•Read only•Restores prevent online activity and vice versa

Log Shipping

•Read only•High latency

Backup/Restore

Page 8: Sqlpass   The Magic Of Replication

Scalability and Availability Options in SQL Server

•High latency•Requires development effortsSSIS

•A mythScalable Shared Databases

•…Replication

Page 9: Sqlpass   The Magic Of Replication

Agenda

• SQL Server’s greatest challenge• Replication overview• Peer-to-Peer Replication • Replication enhancements – SQL Server 2008

Page 10: Sqlpass   The Magic Of Replication

What is Replication?

• “Make copies of digital material for backup, performance, reliability, or preservation”

(Digital Libraries, by William Arms)

• “The use of redundant resources to improve reliability, fault-tolerance, or performance “ (Wikipedia)

Page 11: Sqlpass   The Magic Of Replication

How does it work?

Create a full copy

Identify changes on source (Publisher)

Store changes into distribution database

Distribute changes to destination (subscriber)

Page 12: Sqlpass   The Magic Of Replication

Agenda

• SQL Server’s greatest challenge• Replication overview• Peer-to-Peer Replication • Replication enhancements – SQL Server 2008

Page 13: Sqlpass   The Magic Of Replication

Introduction to Peer-to-Peer Replication

• Databases replicate

reciprocally and are writable

• Redundancy provides fault

tolerance and lowers

maintenance downtime

• Online upgrades possible

Page 14: Sqlpass   The Magic Of Replication

Peer-to-Peer Topology

Distribution Agent

DistDB

Logreader Agent

Distribution Agent

DistDB

Logreader Agent

Los Angeles London

Taipei

Transactional Replication

Distribution Agent

DistDB

Logreader Agent

Page 15: Sqlpass   The Magic Of Replication

Peer-to-Peer– common scenarios

• Scale out reads and writes

or…

• Scale out reads, but writes are done to one node only

Page 16: Sqlpass   The Magic Of Replication

Peer-to-Peer – Multisite solution?

Page 17: Sqlpass   The Magic Of Replication

Back to the DBA’s dream:Peer-to-Peer Replication!• Application/website always online• Workload is distributed amongst many servers

Implementing Peer-to-Peer

Page 18: Sqlpass   The Magic Of Replication

Challenges

• Design your schema and topology properly to prevent conflicts

• P2P is an asynchronous solution and does not guarantee zero data loss or zero latency

• Not completely transparent• Although transparent enough!

Page 19: Sqlpass   The Magic Of Replication

Agenda

• SQL Server’s greatest challenge• Replication overview• Peer-to-Peer Replication • Replication enhancements in

SQL Server 2008

Page 20: Sqlpass   The Magic Of Replication

Changing replication topology online

• In SQL Server 2005, replication had to be stopped (quiesced) in order to perform some actions:• Add nodes• Schema changes

• In SQL Server 2008, these actions can be done online

• And you also get a cool wizard in SSMS…

Page 21: Sqlpass   The Magic Of Replication

Configure Peer-to-Peer Topology Wizard

Demo

Page 22: Sqlpass   The Magic Of Replication

Conflict Detection and Resolution

• SQL Server 2008 introduces

conflict detection capability in

peer-to-peer replication

• All types of conflicts are detected

and reported though agent error

reporting or conflict tables

• Two options on detecting conflict

• Fail replication stream

• Continue stream after

logging conflict

Update tbl_user set Name =‘cameron’

Update tbl_user set Name =‘camern’

Page 23: Sqlpass   The Magic Of Replication

Conflict Detection and Resolution

• Conflicts are resolved based on

originator_id value – higher wins

• Manual resolution of conflicts is

required in most cases

• Best approach: Prevent

conflicts through write

partitioning even with conflict

detection capabilities availableUpdate tbl_user set Name =‘cameron’

Update tbl_user set Name =‘camern’

Page 24: Sqlpass   The Magic Of Replication
Page 25: Sqlpass   The Magic Of Replication

Enabling Conflict Detection

• Enable conflict detection

in publication properties

• Set a value for the

originator ID

• Specify action in case of

conflict:

• Stop and alert (default)

• Continue (may cause data inconsistency)

Page 26: Sqlpass   The Magic Of Replication

Viewing conflicts

• When a conflict occurs, replication will stop by default

• You can view the conflict using Conflict Viewer in SSMS and address it manually

Page 27: Sqlpass   The Magic Of Replication

Conflict Detection and Resolution

Demo

Page 28: Sqlpass   The Magic Of Replication

Replicating partition switch

• In SQL Server 2005, switch partition action was unsupported in replicated environment

• This was a major consideration for organizations when deciding whether to use replication or not

• In SQL Server 2008, you can switch partition on a replicated table, and replicate this action

• Requires some settings in publication properties

Page 29: Sqlpass   The Magic Of Replication

Replicating partition switch

• Publication properties:• @allow_partition_switch: allows SWITCH PARTITION

to be executed against the publication database• @replicate_partition_switch: determines whether the

SWITCH PARTITION DDL statement should be replicated to Subscribers

• Preparations:• Make sure that all tables that are involved in partition

switching exist at the Publisher and Subscriber• Make sure that the table and partition definitions are the

same

• Switch partition using ALTER TABLE command

Page 30: Sqlpass   The Magic Of Replication

Performance improvements

• Under Windows Server 2008, replication works faster than ever:• Snapshot delivery of more than 500MB/minute• One of the interesting benchmarks for a pull

subscriber, time to deliver 100,000 varbinary (max) records:

• Win2003/SQL2005 – 223 minutes

• Win2008/SQL2008 – less than 2 minutes!

Page 31: Sqlpass   The Magic Of Replication

Conclusion

• Peer-to-Peer Replication can provide one of the best methods for systems scale out• Dramatically increase performance• Eliminate downtime

• SQL Server 2008 provides major improvements for Peer-to-Peer Replication, and makes it accessible and more robust

Page 32: Sqlpass   The Magic Of Replication

Related sessions

• Building a High Availability Strategy for your Enterprise

Gopal Ashok

Wednesday, 10:15AM

• Transactional Replication: Beyond The Basics

Kendal Van Dyke

Thursday, 4:00PM

Page 33: Sqlpass   The Magic Of Replication

Q&A

Page 34: Sqlpass   The Magic Of Replication

Complete the Evaluation Form & Win!

• You could win a Dell Mini Netbook – every day – just for handing in your completed form! Each session form is another chance to win!

Pick up your Evaluation Form:• Within each presentation room• At the PASS Booth near registration area

Drop off your completed Form:• Near the exit of each presentation room• At the PASS Booth near registration area

Sponsored by Dell

Page 35: Sqlpass   The Magic Of Replication

Thank youfor attending this session and the 2009 PASS Summit in Seattle