Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 Ch 12. Replication

2 Replication Place copies of data to a different location Use: Reduce locking conflict when multiple sites want to work on same set of data Remove impact from read-intensive tasks such as running reports Allow each location to be configured by their own rule

3 Replication Strategies Replication Not guaranteed synchronized at all time (will eventually be synchronized) Distributed Transaction Guaranteed to be synchronized at each location, data transferred via transaction

4 Parts of a replication Publisher – source database contain publication and articles Publication – a group of articles made available by publisher Article – a piece of data in a publication Subscriber – subscribe to publisher to obtain publication/data Distributor – a server to handle data from a subscriber, and store / forward to other subscribers

5 What can be replicated Data Stored procedures User-defined functions

6 Types of Replication SnapShot Replication Move entire copy to the destination Read-only On-demand Transaction Replication Read-only Transaction Replication with Immediate Updating Subscribers Read/Write Merge Replication Read/Write On-demand, multi-directional

7 Types of Replication Pull subscription Subscriber determine when to get new data Push subscription Distributor determine when to output new data to its subscribers

8 Create a test database and table This code will create a database named dbSource, and a table named Employee with ID as primary key CREATE DATABASE dbSource GO USE dbSource CREATE TABLE EmployeeTrans1 ( ID INT IDENTITY PRIMARY KEY, EmployeeName nvarchar(50) ) GO CREATE TABLE EmployeeTransUpdate1 ( ID INT IDENTITY PRIMARY KEY, EmployeeName nvarchar(50) ) GO

9 Create a test database and table CREATE TABLE EmployeeSnapshot1 ( ID INT IDENTITY PRIMARY KEY, EmployeeName nvarchar(50) ) GO CREATE TABLE EmployeeMerge1 ( ID INT IDENTITY PRIMARY KEY, EmployeeName nvarchar(50) ) GO Enter some data into table Create a dbDestination database to receive data

10 Steps to setup replication Install Distribution Server 1. Open SSMS 2. Right-Click on Replication, select Configure Distribution to start wizard 3. On Distributor screen, select Server will act as its own distributor 4. On Snapshot Folder screen, use default

11 Steps to setup replication 5. On Distribution database page, enter ‘Distributor’ as name of distribution database name 6. On Publishers page, check your server name 7. On Wizard Action page, select ‘Configure distribution’ 8. Finish

12 Steps to setup replication Create a Publisher 1. Expand replication, right-click Location Publication, select New Publication 2. On Publication Database page, select the source database (dbSource) 3. On Publication Type page, select the type of publication (Transactional publication)

13 Steps to setup replication 4. In Articles page, check Employee table, and click on Article Properties 5. In Article Properties, set Destination object name to EmployeeTrans2 6. Click ok to go back to Articles page, and click next 7. Click next on Filter table rows page 8. On Snapshot Agent page, check Create a Snapshot Immediately and click next

14 Steps to setup replication 9. On Agent Security page, click Security Setting button 10. On Snapshot Agent Security pop-up, select Run Under SQL Service Account, and click OK, then click next 11. On Wizard Action page, select Create the Publication and select next 12. On Complete Wizard page, type in pubTransaction into publication name and press finish.

15 Steps to setup replication Create a Subscriber 1. Expand replication, right-click Location Publication, select New Subscriber 2. On Publication page, select pubTransaction, click next 3. On Distributed Agent Location page, select Run Each Agent at its Subscriber 4. On Subscribers page, select your server and select dbDestination as Subscription Database

16 Steps to setup replication 5. On Distribution Agent Security page, click ellipsis (…) and select Run under the SQL Server Agent account, click ok and then next 6. On Synchronization Schedule, set Agent Schedule to Run Continuous and click next 7. On Initialize Subscription page, select Initialize Immediately 8. On Wizard Action page, check Create the subscriptions and click next 9. On Complete the Wizard page, select Finish

17 Steps to setup replication Go through the Publication/Subscription for each types of replication Transactional Update Immediate Subscriber Snapshot Merge

18 Test replication In each table, enter a record check replicated tables in the dbDestination Enter a record in each table in replicated tables Check source tables in dbSource

19 Monitor Replication Right-click on Replication, select Replication Monitor Expand server to view your publication Common jobs Warnings and Agents – click configure to setup warnings/alerts.


Download ppt "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."

Similar presentations


Ads by Google