Module 11: Introducing Replication
Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL Server Replication Types Physical Replication Models
Introduction to Distributed Data The Need for Distributed Data Considerations for Distributing Data Methods to Distribute Data
The Need for Distributed Data Brings Data Closer to the User Allows Site Independence Separates Online transaction processing Read-intensive applications Can Reduce Conflicts
Considerations for Distributing Data Factors Timing/Latency Site Autonomy Transactional ConsistencyReplicationReplication UPDATE Distributed Transactions UPDATE
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 Autonomy Lower Latency Lower Autonomy Lower Latency Higher Autonomy Higher Latency Higher Autonomy Higher Latency Merge Replication
Introduction to SQL Server Replication The Publisher-Subscriber Metaphor Publications and Articles Filtering Data Subscriptions
The Publisher-Subscriber MetaphorPublisherPublisher Maintains source databases Makes data available for replication DistributorDistributor Receives data changes Stores metadata, history, and receives and stores changes May forward changes to subscribers Holds copy of dataSubscriberSubscriber
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
Filtering Data Subscriber Vertical Filtering Horizontal Filtering ABCDEF ABCDEF ABE ABCDEF Table A Table B Publisher
Subscriptions Subscriber 3 Push Subscription Publication B Subscriber 2 Push Subscription Subscriber 1 Push Subscription Publication A Pull Subscription
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
SQL Server Replication Types Overview of the Replication Types Considerations for Using Merge Replication
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
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
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
Overview of the Physical Replication Models Central Subscriber/Multiple Publishers Publisher/ Distributor Subscriber Publisher/ Distributor Multiple Publishers/Multiple Subscribers Publisher/ Distributor/ Subscriber Publisher/ Distributor/ Subscriber Publisher/ Distributor/ Subscriber Subscribers Publisher/ Distributor Central Publisher/Distributor
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
Central Publisher/Remote Distributor Example New York Publisher London Subscribers Rome Paris Dublin Remote Distributor
Central Subscriber/Multiple Publishers Example Region1 Orders Primary Key Reg_code IdId IdId Order_no ~~~~ ~~~~ Qty Region2 Orders Primary Key Reg_code IdId IdId Order_no ~~~~ ~~~~ Qty Region4 Orders Primary Key Reg_code IdId IdId Order_no ~~~~ ~~~~ Qty Region3 Orders Primary Key Reg_code IdId IdId Order_no ~~~~ ~~~~ Qty Publisher Subscriber Master Orders Primary Key Reg_code IdId IdId Order_no ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ Qty ~~~~ ~~~~ ~~~~ ~~~~ 43 30
Multiple Publishers/Multiple Subscribers Example Orders (Shop A) Primary Key Area IdId IdId Order_no ~~~~~~~~~~~~ ~~~~~~~~~~~~ Qty ~~~~ Orders (Shop B) Primary Key Area IdId IdId Order_no ~~~~~~~~~~~~ ~~~~~~~~~~~~ Qty ~~~~ 32 8 Orders (Shop C) Primary Key Area IdId IdId Order_no ~~~~~~~~~~~~ ~~~~~~~~~~~~ Qty ~~~~ ~~~~ Publisher/Subscriber
Recommended Practices Determine the Acceptable Degree of Data Latency Select an Appropriate Replication Type Select the Physical Replication Model Determine Whether to Allow Updates to Replicated Data
Lab A: Implementing Replication
Review Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL Server Replication Types Physical Replication Models