lect 07 data replication
TRANSCRIPT
Lecture 7 Data Replication
Department of Computer Science, Kardan University
Distributed Database System2015
Data Replication in SQL Server 2012Lect-7
Prepared byBilal Khan
Lecture 7 Data Replication
2
The word replication comes from the Latin word replicare, which means to repeat.
Replication describes the process of reproducing or duplicating
Storing a separate copy of database at each of two or three or more sites
Replication
Lecture 7 Data Replication
3
Replication in SQL Server does exactly that; it reproduces or duplicates data.
That copy can exist in the same database as the source data, in a different database on the same instance, or in a database on a separate instance or server.
Replication
Lecture 7 Data Replication
4
SQL Server replication is about more than just copying data.
In SQL Server replication is to continuously synchronize the source data with the copied data or set it up to synchronize the data at scheduled intervals.
Plus, replication supports both one-way and bi-directional synchronization.
Replication
Lecture 7 Data Replication
5
Reliability.
Fast response.
May avoid complicated distributed transaction integrity routines (if replicated data is refreshed at scheduled intervals.)
De-couples nodes (transactions proceed even if some nodes are down.)
Reduced network traffic at prime time (if updates can be delayed.)
Advantages of Replication
Lecture 7 Data Replication
6
Additional requirements for storage space.
Additional time for update operations.
Complexity and cost of updating.
Integrity exposure of getting incorrect data if replicated data is not updated simultaneously.
Therefore, better when used for non-volatile data.
Disadvantages of Replication
Lecture 7 Data Replication
7
Replication requires a number of components to work properly.
Replication Architecture in SQL Server
Lecture 7 Data Replication
8
Artical
The objects that are replicated like tables, views, and stored procedures are called articals.
Replication Architecture in SQL Server
dbo.tbl_3 and dbo.tbl_4 are two articles
Lecture 7 Data Replication
9
Artical
An article's properties determine whether that article contains the entire object or a part of object.
Multiple articles can be created on a single object.
Replication Architecture in SQL Server
Lecture 7 Data Replication
10
Publication
A Publication is group of related data and objects that we want to replicate together.
A publication is a collection of articles grouped together as one unit.
Every article is defined to be part of exactly one publication. However, you can define different articles on the same object in separate publications.
Replication Architecture in SQL Server
Lecture 7 Data Replication
11
Publisher
A Publisher is a server that is the source of data to be replicated.
The Publisher is the SQL Server instance that makes a publication available for replication;
Publisher itself doesn't actually have an active role in a replication setup. After the publication is defined, the Distributor and sometimes the Subscriber do all the heavy lifting.
Replication Architecture in SQL Server
Lecture 7 Data Replication
12
Subscriber
There are two types of subscriptions:
Push subscriptions The Distributor directly updates the data in the Subscriber database.
Pull subscriptions The Subscriber asks the Distributor regularly if any new changes
are available, and then updates the data in the subscription database itself.
Replication Architecture in SQL Server
Lecture 7 Data Replication
13
Subscriber
A database that is the target of a replication subscription is called a subscription database.
Replication Architecture in SQL Server
Lecture 7 Data Replication
14
Subscriber
A Subscriber is a server that receives the data replicated by the publisher.
The Subscriber defines a subscription to a particular publication.
Each subscription creates a link, between one publication and one Subscriber.
Replication Architecture in SQL Server
Lecture 7 Data Replication
15
Distributor A Distributor is a server that performs various tasks
when moving articles from Publishers to Subscribers.
The actual tasks performed depend on the type of replication performed.
Replication Architecture in SQL Server
Lecture 7 Data Replication
16
Distributor Each Publisher is linked to a single Distributor.
The Distributor identifies changes to the articles on each of its Publishers.
The Distributor notify the Subscribers that an article has changed.
The information about changes are stored in the distribution database until all Subscribers have been notified or the retention period has expired.
Replication Architecture in SQL Server
Lecture 7 Data Replication
17
Replication agents Agents are the software components used in replication.
The replication processes are executed by a set of replication agents.
Replication Architecture in SQL Server
Lecture 7 Data Replication
18
Snapshot Agent
Log Reader Agent
Distribution Agent
Types Of SQL Server Replication Agents
Lecture 7 Data Replication
19
Snapshot Agent
Snapshot is a state of any thing at a particular moments.
Snapshot Agent run at least one for any types of Replication.
The Snapshot Agent provides the data required to perform the initial synchronization of the publication database with the subscription database.
Types Of SQL Server Replication Agents
Lecture 7 Data Replication
20
Log Reader Agent
The Log Reader Agent reads the transaction log of the publication database.
If it finds changes to the published objects, it records those changes to the distribution database.
Types Of SQL Server Replication Agents
Lecture 7 Data Replication
21
Distribution Agent
Distribution Agent It performs different activities, mainly distributes publication to subscribers.
The Distribution Agent applies the changes recorded in the distribution database to the subscription database. Only transactional replication uses the Distribution Agent.
Types Of SQL Server Replication Agents
Lecture 7 Data Replication
22
Replication Models
Central Publisher / Distributor
Publ/Dist Sever
Lecture 7 Data Replication
23
Replication Models
Publisher / Remote Distributor
Publisher
RemoteDistr
Lecture 7 Data Replication
24
Snapshot Replication
Transaction Replication.
Merge Replication
Replication Types
Lecture 7 Data Replication
25
Snapshot Replication Snapshot replication creates an identical copy of the
replicated objects and their data each time it runs.
It always copy the entire dataset again and applied to the target database.
Replication Types
Lecture 7 Data Replication
26
Snapshot Replication All other replication types use Snapshot Replication in
first step, by default, a single replication snapshot to sync the Publisher to its Subscribers.
Can be push or pull
Replication Types
Lecture 7 Data Replication
27
Transaction Replication Transactional replication copies data uni-directionally
from the source database to the target database.
This replication type uses the log files associated with the source database to keep data in sync. If a change is made to the source database, that change can be immediately synced to the target database, or the synchronization can be scheduled.
Replication Types
Lecture 7 Data Replication
28
Transaction Replication Transactional replication, however, is sensitive to
changes to the target database. Any change can break replication so, the target database should be considered read-only.
You can modify objects in the target database that are not part of the replication setup.
Replication Types
Lecture 7 Data Replication
29
Transaction Replication Transactional replication works on a transaction basis.
The Log Reader Agent scans the transaction log of the publication database and examines each committed transaction to determine whether any changes affect the replicated articles. If they do, those changes are logged to the distribution database.
The Distribution Agent then replicates those changes to the Subscriber.
Replication Types
Lecture 7 Data Replication
30
Merge Replication Merge replication allows two or more databases to be
kept in sync. Any change applied to one database will automatically be applied to the other databases – and vice versa.
Replication Types
Lecture 7 Data Replication
31
Merge Replication Merge replication allow data changes on the Publisher
as well as the Subscriber,
Merge replication also allows for disconnected scenarios.
◦ For example, if a Subscriber is disconnected from a Publisher during part of the day, the Subscriber and Publisher are synchronized when they are reconnected.
Replication Types
Lecture 7 Data Replication
05/03/202332
Have a Nice Day