SQL Server Replication HILARY COTTER SQL SERVER MVP

Slides:



Advertisements
Similar presentations
Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Advertisements

Mecanismos de alta disponibilidad con Microsoft SQL Server 2008 Por: ISC Lenin López Fernández de Lara.
SQL Server Replication
Moving data using replication Anthony Brown
Adam Thurgar Database Consultant AiT Consultancy Replication with SQL Server ™ – Lessons from the Real World.
Module 14: Scalability and High Availability. Overview Key high availability features available in Oracle and SQL Server Key scalability features available.
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
National Manager Database Services
Passage Three Introduction to Microsoft SQL Server 2000.
Query Processing in Mobile Databases
Module 9: SQL Server 2005 Replication. Overview Overview of Replication Enhancements New Types of Replication Configuring Replication.
SQL Server Replication
SQL Server Replication
70-294: MCSE Guide to Microsoft Windows Server 2003 Active Directory, Enhanced Chapter 7: Active Directory Replication.
SQL Server Replication By Karthick P.K Technical Lead, Microsoft SQL Server.
Implementing Database Snapshot & Database Mirroring in SQL Server 2005 Presented by Tarek Ghazali IT Technical Specialist Microsoft SQL Server MVP Microsoft.
IMS 4212: Distributed Databases 1 Dr. Lawrence West, Management Dept., University of Central Florida Distributed Databases Business needs.
Distributing Data for Availability and Scalability Don Vilen Program Manager SQL Server Microsoft Corporation.
Module 4: Implementing Transactional Replication.
LSC Segment Database Duncan Brown Caltech LIGO-G Z.
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
DAT201: Introduction To SQL Server ™ Replication Matt Hollingsworth Program Manager Microsoft Corporation.
DBSQL 14-1 Copyright © Genetic Computer School 2009 Chapter 14 Microsoft SQL Server.
Module 2: Creating Efficient Replication Solutions.
Triggers A Quick Reference and Summary BIT 275. Triggers SQL code permits you to access only one table for an INSERT, UPDATE, or DELETE statement. The.
Module 1: Exploring Replication. Overview Understanding SQL Server Replication Setting Up Replication Understanding Agents in Replication Securing Replication.
Overview – Chapter 11 SQL 710 Overview of Replication
Copyright © 2006 Quest Software Monitoring SQL Server Replication Presenter : Jim Katsos.
DAT320: Merge Replication in SQL Server 2000: Top 10 How To’s Bren Newman Program Manager Microsoft SQL Server Development.
Module 6: Implementing SQL Server Replication in an Enterprise Environment.
1 Chapter Overview Introducing Replication Planning for Replication Implementing Replication Monitoring and Administering Replication.
Planning Server Deployments Lesson 20. Skills Matrix.
Module 11: Introducing Replication. Overview Introduction to Distributed Data Introduction to SQL Server Replication SQL Server Replication Agents SQL.
Overview of high availability in Microsoft SQL Server Szymon Wójcik.
Zen4Sync: A SQL Server Replication Orchestration Platform Jean-Yves Devant Program Manager - SQL Server Microsoft Corporation Christophe Bigot Senior Analyst.
Chapter 15: Achieving High Availability Through Replication.
DEV333 Instrumenting Applications for Manageability with the Enterprise Instrumentation Framework David Keogh Program Manager Visual Studio Enterprise.
DAT 412:Transactional Replication Internals
ESRI User Conference 2004 ArcSDE. Some Nuggets Setup Performance Distribution Geodatabase History.
 Replication is the process of copying database information  Replication is used for:  Backing up your database  Migrating to a new server  Mirroring.
SQL Server 2005 Implementation and Maintenance Chapter 12: Achieving High Availability Through Replication.
Ing. Erick López Ch. M.R.I. Replicación Oracle. What is Replication  Replication is the process of copying and maintaining schema objects in multiple.
Module 5: Implementing Merge Replication. Overview Understanding Merge Replication Architecture Implementing Conflict Resolution Planning and Deploying.
Enhancing Scalability and Availability of the Microsoft Application Platform Damir Bersinic Ruth Morton IT Pro Advisor Microsoft Canada
DATABASE REPLICATION DISTRIBUTED DATABASE. O VERVIEW Replication : process of copying and maintaining database object, in multiple database that make.
Ch 12. Replication. Replication Place copies of data to a different location Use: Reduce locking conflict when multiple sites want to work on same set.
Migrating Data to SQL Azure Arunraj Chandrasekaran Twitter June 21, 2011.
Log Shipping, Mirroring, Replication and Clustering Which should I use? That depends on a few questions we must ask the user. We will go over these questions.
What HADR Option(s) Are Right For You?. Where’s The AlwaysOn?
Transactional Replication it’s not scary Evgeny Khabarov.
With Temporal Tables and More
How to tune your applications before moving your database to Microsoft Azure SQL Database (MASD) OK, you've jumped into your Azure journey by creating.
Transactional Replication Deep Dive
Glasgow, SQL Server Meetup
Introduction to transactional replication
Navigating the options for Data Redundancy
Temporal Databases Microsoft SQL Server 2016
Lead SQL BankofAmerica Blog: SQLHarry.com
AlwaysOn Mirroring, Clustering
Maximum Availability Architecture Enterprise Technology Centre.
Transactional replication
Introduction to Replication
A Technical Overview of Microsoft® SQL Server™ 2005 High Availability Beta 2 Matthew Stephen IT Pro Evangelist (SQL Server)
Designing an alternative to Replication
Microsoft Replication Technologies
Transactional Replication A Deeper Dive Drew Furgiuele, Senior DBA IGS
Making Sense of Service Broker
Cloud Data Replication with SQL Data Sync
AlwaysOn Availability Groups
Change Tracking Live Data Warehouse
Presentation transcript:

SQL Server Replication HILARY COTTER SQL SERVER MVP

Who am I?  SQL Server MVP – 14 years  20 year IT veteran  Author/coauthor – 6 books  Authors Microsoft courseware  Answer 20,000 questions on Microsoft forums  Some of them correctly  Specializes in replication, full-text search, service broker, performance tuning

Clients

Agenda  Replication Types  Performance Tuning  Troubleshooting  Monitoring

Terms  Publisher  Distributor  Subscriber  Gateway  Article  Schema and data  Schema only (table, indexed views, views, functions, stored procedures)  Stored procedure execution

Replication Types  Snapshot  Transactional  Transactional with updateable subscribers  Bi-Directional Transactional Replication  Peer to Peer  Merge  Sync Services

Replication Use Cases  Used to Distribute/Aggregate data or schema only objects  # 1 use case – offloading reporting  Move data closer to consumer  Avoiding network hop of linked server  Creating Islands of data  Replicating to SQL CE/SQL Compact  Load Balancing/Scale out reads  Peer to Peer  Bi-Directional Transactional  HA/DR  Poor fit  No client redirection  No predictable latency

What is new in SQL 2012/2014  Replication plays nicely with AlwaysON if you are using a remote distributor.  Performance improvements/Bug Fixes  New Extended Events  Sync Services no longer part of the install  Ability to replicate to the Cloud Exposed/Azure-SQL-DB-Transactional-Replication

Replication Extended Events Name logreader_apply_filter_proc logreader_process_text_ptr logreader_process_filestream_info logreader_add_compensation_range logreader_add_eor logreader_add_tran_info logreader_process_text_info

Snapshot Replication  Point in time image of data sent to subscriber  Best fit when the majority of the data changes at one time  Catalogs  Price lists  Poor use cases  Tables don’t have PKs  No real time synchronization requirements

Transactional Replication  Replicates transactions from publisher to subscriber in a transactional context  Store and Forward mechanism  Tlog read asynchronously  Commands constructed and written to distribution database  Markers placed in log saying Transaction X read  LSN – log sequence numbers correlates to  XactSequence in profiler  xact_seqno in msrepl_transactions  Transactional boundaries are respected when applying commands on the subscribe  20 rows updated on publisher  20 rows read by log reader and written to distribution database  20 rows applied on subscriber in a transaction.  Upon failure the 20 row application is rolled back

Demo

Transaction Replication  Can Replicate execution of a stored procedure  Serializable -- SET TRANSACTION ISOLATION LEVEL Serializable; Begin tran tran1 Exec Proc1 Begin tran tran2 Exec proc is committed before 1 Commit tran tran2 Commit tran tran1

Updateable Subscribers  Designed for the case where the majority of the DML originates at the Publisher  Contrast with merge where it is anywhere  Immediate - MS DTC – linked server  committed at publisher before subscriber  Queued  Uses queue reader  Long standing bug in Replication Scripting adds a queue reader for all transactional replication types

Updateable Subscribers  Immediate with queued failover  If Publisher goes down  Published tables go readonly  Deprecated in SQL 2012  Can still use it through stored procedures  Don’t use it  Small user base

Bi-Directional Transactional  Two way replication  No guid key required  Publisher is also a subscriber  sp_addsubscription  Faster than merge and p2p  Only scalable to 2 nodes  Can do three  Great for scaling read outs

Bi-Directional Transactional  demo

Bi-Directional Transactional  Caveats  Swapping data  Identity seeding  Downtime  The longer the downtime the greater the probability of duplicate data

Peer to Peer (P2P)  EE Feature only  Bi-directional  Uses a mesh technology  Each node can replicate to any other nodes in the topology.  A node can drop off and come back on the topology and automatically synchronize  SQL 2008 has conflict detection  No conflict resolution  Smaller feature set the Transactional Replication  No custom stored procedures  Network saturated at 10 nodes

P2P demo

Merge Replication  Designed for frequently disconnected clients which need to bi-directionally replicate  Ideal for POS applications  Uses a tracking column (rowguid) to uniquely identify rows across a replication topology  Uses tracking triggers to do change detection  Merge agent enumerates changes occurring between the publisher and subscriber between synchronizations and downloads changes to either side.  Should a change to a row occur on both sides of a merge replication topology the lineage column on msmerge_contents – sync cookie

Merge Replication  Conflicts  Error  Changes to same row (row level tracking) or column (column level tracking)  Conflict Priority  Server/Global  Client/Local  Determines who conflicts are persisted.  Server – first to publisher wins and persists  Client – determined by assigned priority  Publisher changes always persist

Merge Replication  Conflict resolution  Microsoft SQL Server Additive Conflict Resolver  Microsoft SQL Server Averaging Conflict Resolver  Microsoft SQL Server DATETIME (Earlier Wins) Conflict Resolver  Microsoft SQL Server DATETIME (Later Wins) Conflict Resolver  Microsoft SQL Server Download Only Conflict Resolver  Microsoft SQL Server Maximum Conflict Resolver  Microsoft SQL Server Merge Text Columns Conflict Resolver  Microsoft SQL Server Minimum Conflict Resolver  Microsoft SQL Server Priority Column Resolver  Microsoft SQL Server Subscriber Always Wins Conflict Resolver  Microsoft SQL Server Upload Only Conflict Resolver  Microsoft SQLServer Stored Procedure Resolver

Merge Replication  Web Synchronization  Secure transport  Rich Filtering  Can filter vertically and horizontally  Changes to parent rows will cause motion in child rows.  For example if you are filtering on region, and a sales person gets a new region all the child rows belonging to that region will be replicated down to the sales person’s subscription.  Termed a partition  Precomputed Partitions  Partitions are evaluated at run time (when changes happen) as opposed to filter/sync time  Can result in very short syncs, but sometimes depending on the hierarchies in the filters can result in longer DML time

Business Logic Resolver .Net class that allows you to  Handle Merge Errors  Conflicts  Update  Insert  Delete  Do things on each synchronization  Overhead  Stored Procedure Resolver

Performance Tuning - transactional

Performance Tuning

Merge Replication  Maximize Generations per batch  UploadGenerationsPerBatch  DownloadGenerationsPerBatch  UploadReadChangesPerBatch  DownloadReadChangesPerBatch  UploadWriteChangesPerBatch  DownloadWriteChangesPerBatch  Minimize Conflicts  Minimize Concurrent Merge Agents

Troubleshooting  Enable agents for logging  Run from the command line  Break up publication  For Transactional Replication  sp_replcounters  sp_browsereplcmds  sp_setsubscriptionxactseqno  For Merge Replication – tracking changes  sp_showlineage  sp_showcolv  sp_mergedummyupdate  sp_showpendingchanges

Troubleshooting  Limit number of concurrent merge syncs  sp_changemergepublication 'MyPublication','max_concurrent_merge','10‘  StartQueueTimeout  Reindex merge system tables nightly

Replication and Mirroring  Need a remote distributor  Need to use trace flag 1448

Replication and AGs  Configure your AG  Configure your remote distributor  Configure your Publication  Use Sp_redirect_publisher to have your publisher use the Listener nameSp_redirect_publisher

Questions