sql server 2008 r2...

22
By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication is one of the High Availability features available in SQL Server. Replication is the process of moving data and database schema changes from one database to another database with the use of a snapshot agent, a log reader agent, and a distribution agent. Server and changes happens almost in real time. Replication involves a distributor, a subscriber, a publisher, and articles. Each components need to be configured to make replication function properly. We need to understand the three important terms of Replication. 1. Distribution Database 2. Publisher 3. Subscriber Distribution Database: The distribution database stores metadata and history data for all types of replication and transactions for transactional replication. Distribution database has to keep on a separate server for better performance. Why it is required let say if you keep distribution database on the same machine where publisher database is configured then it always has an impact on the performance of the system because for each publisher, one distrib.exe file get created. Publisher: The Publisher can be referred to as a database on which the DML or DDL schema changes are going to be performed. Subscriber: The Subscriber is the database which is going to receive the DML as well as DDL schema changes which are performed on the publisher.

Upload: others

Post on 10-Oct-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

SQL Server 2008 R2 Replication

High Availability Solution

Replication is one of the High Availability features available in SQL Server. Replication is the process of

moving data and database schema changes from one database to another database with the use of a snapshot agent, a log reader agent, and a distribution agent. Server and changes happens almost in real time.

Replication involves a distributor, a subscriber, a publisher, and articles. Each components need to be configured to make replication function properly.

We need to understand the three important terms of Replication.

1. Distribution Database 2. Publisher 3. Subscriber

Distribution Database:

The distribution database stores metadata and history data for all types of replication and transactions for transactional replication. Distribution database has to keep on a separate server for better performance. Why it is required let say if you keep distribution database on the same machine where publisher database is configured then it always has an impact on the performance of the system because for each publisher, one distrib.exe file get created.

Publisher:

The Publisher can be referred to as a database on which the DML or DDL schema changes are

going to be performed.

Subscriber:

The Subscriber is the database which is going to receive the DML as well as DDL schema

changes which are performed on the publisher.

Page 2: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

Now we will be going to configure the Transactional Replication:

1. Configuring the Distribution Database

2. Creating the Publisher

3. Creating the Subscribers

Configuring the Distribution Database

Follow the below steps to configure the Distribution database.

1. Connect to SQL Server 2008 R2 Management Studio

2. Right click on Replication and select the Configure Distribution.

Page 3: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

3. A new window will appear as given below and click next.

4. According to your requirement select the radio button. If you want to Distributer on the same

sever than select first radio button else second radio button and click on next.

Page 4: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

5. You can configure the SQL Server Agent to start automatically or manually based on your

requirement.

6. In the below screenshot you are asked where the Snapshot folder should reside on the

Server. The Snapshot Agent prepares snapshot files containing schema and data of

published tables and database objects, stores the files in the snapshot folder.

Note: This folder should never be placed on the C drive of the server i.e. the drive which

is hosting the Operating System. Create a folder on any other drive to hold the Snapshot

folder.

Page 5: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

7. In the below screen shot you are going to create the distribution database. You have to provide

the location of DATA and LOG file of database. Always keep Data and Log file in different drives

to get the better IO.

8. Click on next button.

Page 6: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

9. Click on next button to configure the distribution.

10. Click on Finish button to configure the Distribution database.

Page 7: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

11. Below screen shot shows the configuration progress.

12. Once the configuration done than you can check the distribution database under system

database as given below.

Page 8: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

Creating the Publisher

Follow the below steps to create the Publisher

1. Right click on Publication server and select New Publications.

2. Click on the next button.

Page 9: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

3. Select the publication database, I have selected ARCOSDB and click on next.

4. Select the Transactional Replication and click on next.

Page 10: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

5. Select the Objects that you want to publish.

Note: Only those tables can be replicated in Transaction Replication which has a Primary Key column in

it.

6.Click on Next button.

Page 11: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

7. Click on next button and if you want to filer any data based on column than use Add button.

8. Select the first button and click on next.

Page 12: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

9. Click on Security button as given in below screenshot.

10. As given below Select Run under the SQL Server Agent service account as the account under which

the Snapshot Agent process will run and Connect to the publisher by impersonating the process

account, you can also provide SQL Server Login detail based on requirement and then Click on the OK

button.

Page 13: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

11. Click on Next button.

12. Click on Next button.

Page 14: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

13. Now you can see the progess of cnfiguration as given below screen captured.

14. Once all the process completed than you can see the success status as given below screen captured.

Page 15: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

15. Once above process completed than expand the replication > Local Publications >. You can see the

Publication as captured in below screen.

Creating the Subscriber

Once the publisher is successfully created the next step is to create the subscriber.

Follow the steps given below to configure the Subscriber.

1. Right Click on the created publisher and select New Subscriptions as given below.

Page 16: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

2. Click on Next button.

3. Clink on Next button.

Page 17: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

4. Click on Next button.

5. If database is restored than select the database as given below or you can create the new

database by clicking on Dropdown button and select option of New Database.

Page 18: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

6. Click on button here we have to specify the process account and the connection options

for the distribution agent.

7. A new window will appear here you have to specify the distribution agent to run under the SQL

Server Agent Service Account. Also connect to the distributor as well as the subscriber by

impersonating the process account or with the SQL account.

Page 19: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

8. Click Next button.

9. Click on Next button.

Page 20: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

10. Click on Next button.

11. Click on Next button.

Page 21: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

12. Click on Next button.

13. Click on Next button.

Page 22: SQL Server 2008 R2 Replicationdeepakdba.com/wp-content/uploads/2013/12/Transactional-Replicati… · By Deepak Bhardwaj SQL Server 2008 R2 Replication High Availability Solution Replication

By Deepak Bhardwaj

14. Now you can see the configured subscription as given in below screen.

Now you successfully implemented the Transactional Replication.