27
SQL Server Replication Presented by Paul Ibison IT Technical Specialist creator of www.replicationanswers.com responsible for PayPal and EBay replication implementation © 2012 Paul Ibison. All rights reserved.

Presented by Paul Ibison IT Technical Specialist creator of responsible for PayPal and EBay replication

Embed Size (px)

Citation preview

Page 1: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

SQL Server Replication

Presented by Paul IbisonIT Technical Specialist

creator of www.replicationanswers.com responsible for PayPal and EBay replication

implementation

© 2012 Paul Ibison. All rights reserved.

Page 2: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

What is Replication?◦ “Replication is the process of sharing information between

databases (or any other type of server) to ensure that the content is consistent between systems. ”

Transactional Replication◦ Server to Server solution

Merge Replication◦ Offline Database Client solution

Snapshot Replication◦ Point in time copy of objects from one database to

another

Replication Overview

Page 3: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Other “competing” options are◦ Distributed Transactions using MSDTC◦ Backup/Restore◦ Log Shipping ◦ Linked Servers◦ Triggered Solution◦ SSIS◦ Clustering◦ Database Mirroring◦ HADR in SQL 2012

Should I use replication?

Page 4: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

◦ Remote users at distant locations need quick access to data – links are slow to head-office

◦ Mobile disconnected users – links are temporary to head office but people need to work

◦ Disaster recovery???◦ Need quick access to reporting data◦ Need to refresh test environments

Some Business Problems That Require Replication

Page 5: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Reporting and Data Warehousing of Investment Banking Sales Data

Reporting databases are synchronized in near real-time with one or more source OLTP databases

Management reports don’t need to wait for a backup and restore

Page 6: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Oil Exploration – the seismic industry

• Central headquarters data replicated to 16 vessels

• Poor satellite links – slow and sometimes disconnect, but the vessel staff need to continue working!

Page 7: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Veterinary Practices

• Republishing scenario for regional veterinary practices

• Most complex setup I worked with!

Page 8: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

The Publisher-Subscriber Metaphor

• A magazine publisher produces one or more publications

• A publication contains articles

• The publisher either distributes the magazine directly or uses a distributor

• Subscribers receive publications to which they have subscribed

Page 9: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Publications◦ One or more articles ◦ Basis of subscription◦ One or more per database

Articles◦ Tables or parts of tables◦ Views◦ Stored procedures◦ User-defined functions

Publications and Articles

Page 10: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Subscriptions – Push or Pull

Push subscription

Push subscription

Pull subscriptionPull subscription

Subscriber

Subscriber

Publication

Page 11: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Local Distributor

SubscribersPublisher/Distributor

Page 12: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Remote Distributor

PublisherSubscribers

Distributor

Page 13: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Microsoft SQL Server supports the following types of replication:

Snapshot Replication Transactional Replication (updatable

subscriptions for transactional replication deprecated)

Merge Replication

SQL ServerReplication Types

Page 14: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Distributes data as it appears at a moment in time

This type is mostly used when the amount of data to be replicated is small and data/DB objects are static or does not change frequently

Doesn’t require any schema changes or pre-requisites

What Is Snapshot Replication?

Page 15: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Permits low latency replication of data modifications◦ [Never synchronous]

Requires Primary Keys Quick to process Easy to troubleshoot Subscriber data generally read-only Doesn’t deal with conflicts well

What Is Transactional Replication?

Page 16: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

How Transactional Works

Page 17: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Merges the updates between sites when they are connected

Each Subscriber often has a different partition of data

Adds a GUID to each table Allows for conflict resolution Slower to process Can be difficult to troubleshoot

What Is Merge Replication?

Page 18: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

How Merge Works

Page 19: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Replication Agents

SnapshotSnapshot

Snapshot AgentSnapshot Agent

Distribution AgentDistribution Agent

TransactionalTransactional

Snapshot AgentSnapshot Agent

Distribution AgentDistribution Agent

Log Reader AgentLog Reader Agent

[Queue Reader Agent][Queue Reader Agent]

MergeMerge

Snapshot AgentSnapshot Agent

Merge AgentMerge Agent

Agents are the processes (jobs) that are responsible for copying and distributing data between publisher and subscriber. There are different types of agents supporting different types of replication.

Page 20: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Focused on your requests◦ Monitoring & diagnostics◦ Oracle Publishing◦ Transactional

Better high availability Initialization from backup

◦ Merge Performance Synchronization over the web

◦ Schema changes made using the following data definition language (DDL) statements are automatically replicated

◦ Wizard simplicity

Replication Recent Improvements

Page 21: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Oracle PublishingTransactional Replication

Designed specifically for Oracle Publishers– v8+ on any operating system

Administered like SQL Server, from SQL Server– No Oracle side software install necessary

– Requires minimal knowledge of Oracle

Page 22: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Peer To Peer Topology Transactional ReplicationPeer To Peer Topology Transactional Replication

Page 23: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Benefits◦ High availability & scale out of DB applications◦ No single point of failure◦ Allows maintenance without taking applications offline◦ Can scale queries across databases

Setup◦ Using wizard is quite simple and requires no downtime to

existing nodes◦ Publications must all have the same name

Peer to Peer Replication

Page 24: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Benefits◦ Restore a publisher DB backup to deliver the

initial data to a subscriber (instead of snapshot)◦ Subscriber automatically picks up subsequent

changes on the publisher that occurred after the backup

Setup◦ Set the “allow initialization with backup”

publication option◦ Restore a subsequent publisher backup to the

subscriber

Transactional - Initialization using a DB Backup

Page 25: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Web Synchronization Merge Replication

Publisher/Distributor

Firewall

IISSubscriber

Replisapi.dll

• No VPN or port required• Eases deployment of mobile

applications• Off by default• Secure by default• Only authenticated users can send

request • Requires HTTPS

XML over HTTPS Binary over TCP/IP

Page 26: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Microsoft SQL Server 2008 Express Edition can serve as a Subscriber for all types of replication, providing a convenient way to distribute data to client applications that use this edition of SQL Server.

When using SQL Server 2008 Express Edition in a replication topology, keep the following considerations in mind: ◦ SQL Server 2008 Express Edition cannot serve as a Publisher or

Distributor. However, merge replication allows changes to be replicated in both directions between a Publisher and Subscriber.

◦ SQL Server 2008 Express Edition does not include SQL Server Agent, which is typically used to run replication agents. If you use a pull subscription (in which agents run at the Subscriber), you must synchronize the subscription using Windows Synchronization Manager or RMO.

Replicating Data to SQL Server Express

Page 27: Presented by Paul Ibison IT Technical Specialist creator of  responsible for PayPal and EBay replication

Microsoft Resources:◦ msdn.microsoft.com/sqlserver/◦ www.microsoft.com/sql/community

Contact me: ◦ [email protected]

Websites:◦ www.replicationanswers.com◦ http://blogs.msdn.com/b/repltalk/

Resources & Questions