module 11: introducing replication. overview introduction to distributed data introduction to sql...

24
Module 11: Introducing Repli cation

Upload: lee-knight

Post on 03-Jan-2016

234 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Module 11: Introducing Replication

Page 2: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Overview

Introduction to Distributed Data

Introduction to SQL Server Replication

SQL Server Replication Agents

SQL Server Replication Types

Physical Replication Models

Page 3: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Introduction to Distributed Data

The Need for Distributed Data

Considerations for Distributing Data

Methods to Distribute Data

Page 4: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

The Need for Distributed Data

Brings Data Closer to the User

Allows Site Independence

Separates

Online transaction processing

Read-intensive applications

Can Reduce Conflicts

Page 5: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Considerations for Distributing Data

Factors

Timing/Latency

Site Autonomy

Transactional Consistency

ReplicationReplicationReplicationReplication

UPDATE

Distributed TransactionsDistributed TransactionsDistributed TransactionsDistributed Transactions

UPDATE UPDATE

Page 6: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Methods to Distribute Data

Snapshot Replication

Transactional Replication

Snapshot Replication with Immediate or Queued Updating Subscriptions

Transactional Replication with Immediate or Queued

Updating Subscriptions

Distributed Transactions

Lower AutonomyLower Latency

Lower AutonomyLower Latency

Higher AutonomyHigher Latency

Higher AutonomyHigher Latency

Merge Replication

Page 7: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Introduction to SQL Server Replication

The Publisher-Subscriber Metaphor

Publications and Articles

Filtering Data

Subscriptions

Page 8: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

The Publisher-Subscriber Metaphor

PublisherPublisherPublisherPublisher

Maintains source databases

Makes data available for replication

DistributorDistributorDistributorDistributor

Receives data changes

Stores metadata, history, and receives and stores changes

May forward changes to subscribers

Holds copy of data

SubscriberSubscriberSubscriberSubscriber

Page 9: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Publications and Articles

Publication The basis of a subscription A collection of one or more articles Can have one or more publications per database

Article

Data from a whole or filtered partition of a table or a database object

Part of a publication

Page 10: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Filtering Data

Subscriber

Vertical Filtering

Horizontal Filtering

234567

1A B C D E F

234567

1A B C D E F

234567

1A B E

36

2A B C D E F

Table A

Table B Publisher

Page 11: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Subscriptions

Subscriber 3Subscriber 3Subscriber 3Subscriber 3

Push Subscription

Push Subscription

Push Subscription

Push SubscriptionPublication BPublication BPublication BPublication B

Subscriber 2Subscriber 2Subscriber 2Subscriber 2

Push Subscription

Push Subscription

Push Subscription

Push SubscriptionSubscriber 1Subscriber 1Subscriber 1Subscriber 1

Push SubscriptionPush SubscriptionPush SubscriptionPush Subscription

Publication APublication APublication APublication A

Pull SubscriptionPull SubscriptionPull SubscriptionPull Subscription

Page 12: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

SQL Server Replication Agents

Snapshot Agent

Prepares initial snapshots and stores them on the distributor Distribution Agent

Moves snapshot and transactional data to Subscribers Log Reader Agent

Copies data from transaction log to the distribution database Merge Agent

Merges changes from multiple sites Queue Reader Agent

Applies changes from a queue and applies them to multiple subscribers

Page 13: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

SQL Server Replication Types

Overview of the Replication Types

Considerations for Using Merge Replication

Page 14: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Overview of the Replication Types

Snapshot Replication

Periodic bulk transfer of new snapshots of data

Transactional Replication

Replication of incremental changes

Merge Replication

Autonomous changes to replicated data are later merged

Page 15: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Considerations for Using Merge Replication

Changes to the Schema

Identifies a unique column Adds several system tables Creates triggers at Publisher and Subscriber

Conflict Resolution

Tracks updates Compares values and resolves conflicts Replicates only synchronized data

Page 16: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Physical Replication Models

Overview of the Physical Replication Models

Combining Physical Replication Models and Types

Central Publisher/Remote Distributor Example

Central Subscriber/Multiple Publishers Example

Multiple Publishers/Multiple Subscribers Example

Page 17: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Overview of the Physical Replication Models

Central Subscriber/Multiple PublishersCentral Subscriber/Multiple PublishersCentral Subscriber/Multiple PublishersCentral Subscriber/Multiple Publishers

Publisher/Distributor

SubscriberPublisher/Distributor

Publisher/Distributor

Publisher/Distributor

Multiple Publishers/Multiple SubscribersMultiple Publishers/Multiple SubscribersMultiple Publishers/Multiple SubscribersMultiple Publishers/Multiple Subscribers

Publisher/Distributor/Subscriber

Publisher/Distributor/Subscriber

Publisher/Distributor/Subscriber

Subscribers

Publisher/Distributor

Central Publisher/DistributorCentral Publisher/DistributorCentral Publisher/DistributorCentral Publisher/Distributor

Page 18: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Combining Physical Replication Models and Types

The Model Is the Physical Implementation

The Type Provides the Functionality

Any of the Models Can Use Any of the Types

Page 19: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Central Publisher/Remote Distributor Example

New York

Publisher

London

Subscribers

Rome

Paris

Dublin

RemoteDistributor

Page 20: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Central Subscriber/Multiple Publishers Example

RRegion1 Ordersegion1 OrdersRRegion1 Ordersegion1 OrdersPrimary KeyPrimary Key

Reg_codeReg_code IdId Order_noOrder_no

1 1

1 1

10003100

10003100

~~

~~

QtyQty

1522

1522

RRegion2egion2 Orders OrdersRRegion2egion2 Orders OrdersPrimary KeyPrimary Key

Reg_codeReg_code IdId Order_noOrder_no

2 2

2 2

10002380

10002380

~~

~~

QtyQty

328

328

RRegion4 Ordersegion4 OrdersRRegion4 Ordersegion4 OrdersPrimary KeyPrimary Key

Reg_codeReg_code IdId Order_noOrder_no

4 4

4 4

10002000

10002000

~~

~~

QtyQty

4330

4330

RRegion3 egion3 OrdersOrdersRRegion3 egion3 OrdersOrdersPrimary KeyPrimary Key

Reg_codeReg_code IdId Order_noOrder_no

3 3

3 3

10001070

10001070

~~

~~

QtyQty

719

719

Publisher

Publisher

Publisher

Publisher Subscriber

MasterMaster O OrdersrdersMasterMaster O OrdersrdersPrimary KeyPrimary Key

Reg_codeReg_code IdId Order_noOrder_no

1 1 2 2 3 3 4 4

1 1 2 2 3 3 4 4

10003100100023801000107010002000

10003100100023801000107010002000

~~~~~~~~

~~~~~~~~

QtyQty

1 1 2 2 3 3 4 4

1 1 2 2 3 3 4 4

11

10003100

~~

1522

22

10002380

~~

328

33

10001070

~~

719

44

10002000

~~

4330

Page 21: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Multiple Publishers/Multiple Subscribers Example

OOrders rders (Shop A)(Shop A)OOrders rders (Shop A)(Shop A)Primary KeyPrimary Key

AreaArea IdId Order_noOrder_no

1 12233

1 12233

100031001000238010001070

100031001000238010001070

~~~~~~

~~~~~~

QtyQty

15223287

19

15223287

19

11

10003100

~~

1522

OOrders rders (Shop B)(Shop B)OOrders rders (Shop B)(Shop B)Primary KeyPrimary Key

AreaArea IdId Order_noOrder_no

112233

112233

100031001000238010001070

100031001000238010001070

~~~~~~

~~~~~~

QtyQty

15223287

19

15223287

19

22

10002380

~~

328

OOrders rders (Shop C)(Shop C)OOrders rders (Shop C)(Shop C)Primary KeyPrimary Key

AreaArea IdId Order_noOrder_no

112233

112233

100031001000238010001070

100031001000238010001070

~~~~~~

~~~~~~

QtyQty

15223287

19

15223287

19

33

33

10001070

10001070

~~

~~

719

719

Publisher/Subscriber

Publisher/SubscriberPublisher/Subscriber

Page 22: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Recommended Practices

Determine the Acceptable Degree of Data LatencyDetermine the Acceptable Degree of Data Latency

Select an Appropriate Replication TypeSelect an Appropriate Replication Type

Select the Physical Replication ModelSelect the Physical Replication Model

Determine Whether to Allow Updates to Replicated DataDetermine Whether to Allow Updates to Replicated Data

Page 23: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Lab A: Implementing Replication

Page 24: Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL

Review

Introduction to Distributed Data

Introduction to SQL Server Replication

SQL Server Replication Agents

SQL Server Replication Types

Physical Replication Models