module 2: creating efficient replication solutions
TRANSCRIPT
Module 2:Creating Efficient
Replication Solutions
Overview
Understanding the SQL Server Platform for Replication
Replicating Data and Objects
Replicating Data and Executing Objects
Designing a Replication Topology
Troubleshooting a Replication Implementation
Lesson: Understanding the SQL Server Platform for Replication
Understanding Operating SystemImplications for Replication
Understanding SQL Server Installation Implications for Replication
Understanding Operating System Implications for Replication
Operating systems that CANOperating systems that CANbe used for transactional be used for transactional
replication Publisherreplication Publisher
Operating systems that CANOperating systems that CANbe used for transactional be used for transactional
replication Publisherreplication Publisher
Operating systems that CANNOTOperating systems that CANNOTbe used for transactionalbe used for transactional
replication Publisherreplication Publisher
Operating systems that CANNOTOperating systems that CANNOTbe used for transactionalbe used for transactional
replication Publisherreplication Publisher
Windows NTWindows NT Windows 95Windows 95
Windows 2000Windows 2000 Windows 98Windows 98
Windows XPWindows XP Windows Me, Windows CEWindows Me, Windows CE
Understanding SQL Server Installation Implications for Replication
Licensing
Licensing requirements detailed on www.microsoft.com Character Sets
All servers should use the same character set Collation
Use the same collation at Publisher and Subscriber Sort order
You may use different sort orders at Publisher and Subscriber
Lesson: Replicating Data and Objects
Replicating Table Schema
Planning to Publish Table Schema Objects
Replicating Filtered Data
Replicating Schema Objects – Views, UDFs, and Stored Procedures
Replicating Table Schema
Schema changes required by replication Adding tables to track and manage replication Adding columns to identify records
You can change the name of the destination table or its columns
Changing columns sp_repladdcolumn sp_repldropcolumn On-demand script execution SQL Distributed Management Objects The publication property page
Restrictions on dropping columns
Planning to Publish Table Schema Objects
Primary key constraints
Reference constraints
Unique constraints
Clustered and nonclustered indexes
User triggers
Extended properties
Collation
Replicating Filtered Data
Vertical FilteringVertical FilteringVertical FilteringVertical Filtering
234567
1A B C D E F
234567
1A B E
Table A
Horizontal FilteringHorizontal FilteringHorizontal FilteringHorizontal Filtering
234567
1A B C D E F
36
2A B C D E F
Table B Subscriber Publisher
These Objects
Rely on TheseTables
Replicating Schema Objects – Views, UDFs, and Stored Procedures
CREATE VIEW vw_EmployeeDept AS ...CREATE VIEW vw_EmployeeDept AS ...
CREATE FUNCTION fn_PayPeriod AS ...CREATE FUNCTION fn_PayPeriod AS ...
CREATE VIEW vw_EmployeeDept AS ...CREATE VIEW vw_EmployeeDept AS ...
CREATE FUNCTION fn_PayPeriod AS ...CREATE FUNCTION fn_PayPeriod AS ...
CREATE PROCEDURE pr_ValidateVac AS ...CREATE PROCEDURE pr_ValidateVac AS ...
CREATE PROCEDURE pr_ValidateVac AS ...CREATE PROCEDURE pr_ValidateVac AS ...
Replicate View, UDF, Stored Replicate View, UDF, Stored ProceduresProcedures
REPLICATED SEPARATELYREPLICATED SEPARATELY
Replicate View, UDF, Stored Replicate View, UDF, Stored ProceduresProcedures
REPLICATED SEPARATELYREPLICATED SEPARATELY
Replicate TablesReplicate TablesReplicate TablesReplicate Tables
11 3322
Lesson: Replicating and Executing Objects
Reducing Replication Volume with Stored Procedures
Replicating Indexed Views as Tables
Replicating with On-Demand Script Execution
Preventing Data Inconsistencies from the Execution of Stored Procedures
Reducing Replication Volume with Stored Procedures
UPDATE200,000Rows
The execution of stored proceduresThe execution of stored proceduresThe execution of stored proceduresThe execution of stored procedures
UPDATE200,000Rows
Create stored procedure to update affected rowsCreate stored procedure to update affected rows1111
Publish the stored procedure; replication creates copies on each Subscriber Publish the stored procedure; replication creates copies on each Subscriber 2222
Execute the stored procedure on the PublisherExecute the stored procedure on the Publisher3333
EXEC command is replicatedEXEC command is replicated4444
Update runs locally on SubscribersUpdate runs locally on Subscribers5555
11 3322
Replicating Indexed Views as Tables
Preserve the image of the view data on disk
Allow you to replicate view content instead of schema
Reduce the amount of data to be replicated
Replicating with On-Demand Script Execution
Script execution uses osql.exeScript execution uses osql.exe
Script is replicated Script is replicated 1111
Script executes locallyScript executes locally2222
Script executes locallyScript executes locally2222
Script executes locallyScript executes locally2222
11 3322
TruncateTable
TruncateTable
TruncateTable
TruncateTable
TruncateTable
TruncateTable
TruncateTable
TruncateTable
Subscriber
PublisherEXEC pr_UpdateEXEC pr_Update
Preventing Data Inconsistencies from the Execution of Stored Procedures
UPDATE Table 1
UPDATE Table 2
Table 1Table 1
Table 2Table 2
EXEC pr_UpdateEXEC pr_Update
UPDATE Table 1
Table 1Table 1
UPDATE Table 2Table 2Table 2
Publisher and Subscriber Publisher and Subscriber do not matchdo not match
Publisher and Subscriber Publisher and Subscriber do not matchdo not match
ConstraintViolation
11 3322
Table 2Table 2
ConstraintViolation
Lesson: Designing a Replication Topology
Central Publisher and Distributor
Republisher for a Slow Link
Republisher for Scale Out
Central Subscriber with Partitioned Data
Bidirectional Partitioned Topology
Bidirectional Non-Partitioned Topology
Central Publisher and Distributor
Moscow
Rome
Paris
Athens
London
Berlinheadquarters
Central Publisher Central Publisher and Distributorand Distributor
Central Publisher Central Publisher and Distributorand Distributor
Remote Remote DistributionDistribution
Remote Remote DistributionDistribution
11 3322
Central Publisher Central Publisher and Distributorand Distributor
Central Publisher Central Publisher and Distributorand Distributor
Republisher for a Slow Link
Seattle
San Francisco
Dallas
Sydney
Hong Kong
Beijing
Tokyo
San Francisco publishes to Seattle,
Dallas, and Tokyo
Slow link
Tokyo republishesto Beijing, Hong Kong,
and Sydney
11 3322
Republisher for Scale Out
London
DakarWorldwide
Headquarters
RomeEuropeanHeadquarters
New York
AtlantaNorth American
Headquarters
Caracas
Madrid
Central Subscriber with Partitioned Data
Seattle
New YorkSan Francisco
Dallas headquarters
Mexico City
Bidirectional Partitioned Topology
New York
The New York Office updates customers in the East Region
No conflicts existNo conflicts existNo conflicts existNo conflicts exist
The San Francisco Office updates
customers in the West Region
San Francisco
1
2
3
4
5
6
7
A B C D E F
Bidirectional Non-Partitioned Topology
New York
Both offices update the Both offices update the same datasame data
Both offices update the Both offices update the same datasame data
San Francisco
1
2
3
4
5
6
7
A B C D E F
11 3322
Lesson: Troubleshooting a Replication Implementation
Keep a Performance Baseline
Check Replication Alerts
Look for Errors by Using Replication Monitor
Confirm Mutual Recognition of Servers
Validate Data
Check Subscription Status
Restore the Subscriber to the Current State
Removing Replication
Step 1: Keep a Performance Baseline
Step 2: Check Replication Alerts
Default AlertsDefault AlertsDefault AlertsDefault Alerts
Agent successAgent success
Agent failureAgent failure
Agent retryAgent retry
Subscriber has passed data validationSubscriber has passed data validation
Subscription cleaned upSubscription cleaned up
Subscriber has failed data validationSubscriber has failed data validation
Subscription reinitialized after data validationSubscription reinitialized after data validation
Step 3: Look for Errors by Using Replication Monitor
Step 4: Confirm Mutual Recognition of Servers
Step 5: Validate Data
Validation Options
Compute a fast row count Compute an actual row count Compute a checksum
Use stored procedures to validate a subscription
sp_article_validation
sp_publication_validation
sp_table_validation
Handling validation failures
Practice: Validate Data
Subscribe to a publication
Create an invalid row
Validate data and receive error message
Step 6: Check Subscription Status
sp_helppublication
Information about all publications
sp_helparticle
Information about all articles
sp_helpsubscription
Information about all subscriptions
Step 7: Restore the Subscriber to the Current State
SynchronizeSynchronizeSynchronizeSynchronize
Yes
No
Yes
No
Fixed?Fixed?Fixed?Fixed?
Force Force replicationreplication
Force Force replicationreplication
Fixed?Fixed?
ReinitializeReinitializeReinitializeReinitialize
CompleteCompleteCompleteComplete
Removing Replication
Removal SequenceRemoval SequenceRemoval SequenceRemoval Sequence
Stop the SQL Server Agent Stop the SQL Server Agent
Remove replication with wizardRemove replication with wizard
Delete the distribution databaseDelete the distribution database
Delete the Subscriber tablesDelete the Subscriber tables
PreparationPreparationPreparationPreparation
CreateScriptsCreateScripts
Review
Understanding the SQL Server Platform for Replication
Replicating Data and Objects
Replicating Data and Executing Objects
Designing a Replication Topology
Troubleshooting a Replication Implementation
Lab 2: Implementing Replication
Exercise 1: Determining the Replication Type
Exercise 2: Implementing Snapshot Replication
Exercise 3: Implementing Transactional Replication
Exercise 4: Implementing Merge Replication
Exercise 5: Removing Subscriptions and Publications
Regional OfficeMexico City Local Offices
Regional Offices
Regional OfficeBoston
Regional OfficeLos Angeles
HeadquartersSt. Louis
Regional OfficeAtlanta
Regional OfficeChicago
Lab 2, exercise 1 – Determine the Topology Type