0% found this document useful (0 votes)
1 views

BGI SQL Replication V1

This document provides a comprehensive guide on setting up and configuring SQL Replication in MS SQL Server, detailing the initial setup, user requirements, and necessary firewall configurations. It outlines the steps for configuring the Distributor, Publisher, and Subscriber, including the creation of a publication and subscription for database replication. The tutorial concludes with a successful configuration of a transactional SQL replication model, allowing for data propagation between servers.

Uploaded by

mshajib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

BGI SQL Replication V1

This document provides a comprehensive guide on setting up and configuring SQL Replication in MS SQL Server, detailing the initial setup, user requirements, and necessary firewall configurations. It outlines the steps for configuring the Distributor, Publisher, and Subscriber, including the creation of a publication and subscription for database replication. The tutorial concludes with a successful configuration of a transactional SQL replication model, allowing for data propagation between servers.

Uploaded by

mshajib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 37

BGI SQL Replication: Basic setup and

configuration
By Muntasir Shajib 01-Jul-2021
The tutorial/Blog followed SQL Replication: Basic setup and configuration (sqlshack.com)

Initial setup
Check that you have installed the features required for MS SQL Server replication once the MS SQL Server
installation is complete. Database engine services, such as SQL Server replication and R-Services, must be
selected during MS SQL Server installation

It is recommended to use a single account and password on both servers for replication, I am
creating account sqlrep on
Creating new user

1
The user need to be member of the following groups

 Administrators (local administrators on local machines, not domain administrators)


 SQLRUserGroupMSSQLSERVER1
 SQLServer2005SQLBrowserUser$____

2
Adding new user on SQL SERVER

3
4
5
The following ports must be opened for inbound traffic:

TCP 1433, 1434, 2383, 2382, 135, 80, 443;

UDP 1434.

Don’t forget to configure Windows firewall and enable the appropriate ports for inbound traffic on each host
before installing MS SQL Server. Hosts attended in MS SQL replication must resolve each other by a
hostname.

How to: Configure a Windows Firewall for Database Engine Access

After this need to restart the SQL Service or better to restart the server.

Now you can log in by using Windows authentication on both servers.

6
Importing a database from a backup

7
After importing a database, you have to perform some tuning to prepare your MS SQL servers.

In Server Roles, tick the checkbox next to the dbcreator role.

On the User Mapping page, select users mapped to this login and tick the Bexcom_Final database checkbox
(select BexcomFinal_R on the second server accordingly).

In the database role membership section, tick the db_owner checkbox.

8
Hit OK to save the settings.

Perform a similar configuration on the SQLREP-DW (2nd Server) machine. Then you can configure MS
SQL Server components needed for database replication.

9
We need to configure SQL Replication to copy tables, stored procedures and views
from Bexcom_Final database to another database. We use SQL Server Management Studio. The
transactional replication setup has a single SQL Server instance to play the roles of SQL replication
Distributor, Publisher, and another SQL Server instance play the role of the SQL replication
Subscriber.

Getting Started
To first set up transaction SQL replication on ERP-DB01, we must configure the SQL replication
Distributor and create a SQL replication Publication, replication snapshot folder and a SQL
replication Subscription.

Configure Distributor
The following steps walk you through the process of creating the SQL replication Distributor:

1. Open SSMS and connect to the SQL Server instance

10
2. In Object Explorer, browse to the replication folder, right-click the Replication folder, and
click Configure Distribution

3. The first page of the Distribution Configuration Wizard appears. The pages outline the
general details about configuration distributor aka Configure Distribution Wizard

11
4. On the Distributor page, we have an option to choose to set up the current instance to be
a Distributor or select another instance that’s already been configured as a Distributor. We
don’t have any other option so Click Next.

12
5. Next, in the configure Snapshot Folder, type in the path of the SQL replication snapshot
folder or leave the default path of the SQL replication snapshot folder. The snapshot folder
is used for initial data synchronization of transactional replication and make sure it is large
enough to hold all the replicated data. In this case, I’ll leave the default values and
Click Next.

6. Now, configure the SQL replication distribution database. Specify the name of the
distribution database and the folders where the data and log files should be located. Again,
no change in the default values is required. Click Next.

13
7. In the Publishers page, specify the SQL replication Publishers that are going to access the
Distributor and Click Next

14
8. In Wizard Actions, havee an option to run immediately or create a script that can be
executed at a later time and Click Next

9. In the complete the wizard page, Review the settings and configuration options, and then
click Finish to enable the Distributor

15
10. Now, for Configuring… the following page appears and it shows the progress of the
distributor setup.

16
Configure Publisher
Once you’ve configured the Distributor, you can create a publication. Let’s follow the steps:

1. In Object Explorer, locate the Replication folder, right-click Local Publication, and
then click New Publication

2. Next, the New Publication Wizard appears and outlines the general information about
creating Publication.

17
3. In the Publication Database page, select the Bexcom_Final database and click Next.

18
4. On the Publication Type page, select Transactional publication, and click Next.

5. Now, on the Articles page, choose the articles should be part of this publication

19
It Better to select only require tables and view remember the table that don’t have any
primary key will not be replicated
here we are selecting all Tables and View

6. Once you’re done with the object selection, Check the Show only checked articles in
the list option to list candidates of Publication. In this case, 2 tables, 1 Stored Procedures
are selected.

20
7. Next, in the Filter Table Rows page, define filters that should be applied to your articles.
Let us go with the default values.

21
8. In the Snapshot Agent page specify when to run the Snapshot Agent. It can be run
immediately or it can schedule to run at a later time. In this case, Create a
snapshot immediately is used.

22
9. Now, in the Agent Security page, specify the account to use to run the Snapshot Agent
using Security settings…

23
10. Click Ok

24
11. In the complete Wizard Actions page, you’ve two options. You can create the Publication
immediately or save the configuration in the script file to run at a later time.

25
12. Type in the publication name and Click Finish.

26
13. In the Creating Publication page, you’ll find information about the wizard’s progress as it
works through each step of the process.

14. Now, you can see that Publication is created under the local publication folder

Configure Subscriber
The final step in setting up replication is to create the subscription. Let us walk-through the
steps:

27
As you recall, MS SQL Server replication can be either pull or push replication. If you configure push
replication, you should configure the Subscriber to run agents on the main database server (ERP-DB01 in
this case). If you configure pull replication, the Subscriber must be configured to run agents on the second
machine (SQLREP-DW), i.e. the machine on which the database replica will be created. Let’s configure
push replication and create a new subscription on the first MS SQL Server (ERP-DB01) where the master
database resides.

1. In Object Explorer, go to Replication, right click Local Subscriptions and, in the context menu,
select New Subscriptions

2. The New Subscription Wizard appears outlines the general information about the wizard.

28
3. On the Publication page, select Publication and then click Next

29
4. On the Distribution Agent location page, select “Run all agents at the Distributor” and
Click Next

5. On the Subscribers page, select Add Subscriber, and then select Add SQL Server
Subscriber from the drop-down. This step opens the Connect to Server dialog box. Enter the
subscriber instance name and then select Connect.

30
6. After the subscriber SQL instance has been added, select the drop-down next to the
instance name of your subscriber. Then select New Database under Subscription
Database and type in the database name and Click Ok.

31
7. The subscription database is created and registered to the subscriber. Now, click Next.
Make sure that the account has db_owner permission on the newly created database.

8. On the Distribution Agent Security page, select the ellipsis (…) button. Type in the
process account details and Click Ok.

32
9. Select Finish accepting the default values on the remaining pages and completing the
wizard.

33
For schedule click on “Run Continuously”

34
35
10. On the complete the wizard page, you can see the detailed summary of the newly created
subscription. Click Finish

11. In the Creating Subscription(s)…page should show that the process has been successful

or not.
36
12. Connect to the publisher in SQL Server Management Studio. In the Object explore, right-
click the Replication folder, and then select Launch Replication Monitor to verify the status
of the newly created transactional replication setup.

SQL replication wrap Up


In this article, we’ve successfully configured Publisher, Local Distributor and a remote
Subscriber transactional SQL replication model. You can now insert, delete, or update the
data in the Address and AddressType articles to see the data propagation mechanism
between the servers.

In the next article, we will see how to run rebuild the setup using a backup file. Stay
tuned…

37

You might also like