Create Windows Accounts For Replication
Create Windows Accounts For Replication
Create Windows Accounts For Replication
Note
In the replication tutorials, the publisher and distributor share the same instance
(NODE1\SQL2016) of SQL Server. The subscriber instance (NODE2\SQL2016) is remote.
The publisher and subscriber might share the same instance of SQL Server, but it is not a
requirement. If the publisher and subscriber share the same instance, the steps that are used
to create accounts at the subscriber are not required.
6. Select Close.
1. In File Explorer, browse to the SQL Server data folder. The default location is
C:\Program Files\Microsoft SQL Server\MSSQL.X\MSSQL\Data.
2. Create a new folder named repldata.
3. Right-click this folder and select Properties.
a. On the Sharing tab in the repldata Properties dialog box, select Advanced
Sharing.
b. In the Advanced Sharing dialog box, select Share this Folder, and then select
Permissions.
REPLICATION FOR SQLSSERVER
4. In the Permissions for repldata dialog box, select Add. In the Select User,
Computers, Service Account, or Groups box, type the name of the Snapshot
Agent account that you created previously, as
<Publisher_Machine_Name>\repl_snapshot. Select Check Names, and then select
OK.
5. Repeat step 6 to add the other two accounts that you created previously:
<Publisher_Machine_Name>\repl_merge and
<Publisher_Machine_Name>\repl_distribution.
6. After you add the three accounts, assign the following permissions:
o repl_distribution: Read
o repl_merge: Read
o repl_snapshot: Full Control
REPLICATION FOR SQLSSERVER
7. After your share permissions are configured correctly, select OK to close the
Permissions for repldata dialog box. Select OK to close the Advanced Sharing
dialog box.
8. In the repldata Properties dialog box, select the Security tab and select Edit:
9. In the Permissions for repldata dialog box, select Add. In the Select Users,
Computers, Service Accounts, or Groups box, type the name of the Snapshot
Agent account that you created previously, as
REPLICATION FOR SQLSSERVER
10. Repeat the previous step to add permissions for the Distribution Agent as
<Publisher_Machine_Name>\repl_distribution, and for the Merge Agent as
<Publisher_Machine_Name>\repl_merge.
11. Verify that the following permissions are allowed:
o repl_distribution: Read
o repl_merge: Read
o repl_snapshot: Full Control
12. Select the Sharing tab again and note the Network Path for the share. You'll need
this path later when you're configuring your snapshot folder.
REPLICATION FOR SQLSSERVER
Configure distribution
In this section, you configure distribution at the publisher and set the required permissions
on the publication and distribution databases. If you have already configured the distributor,
you must disable publishing and distribution before you begin this section. Do not do this if
you must keep an existing replication topology, especially in production.
Configuring a publisher with a remote distributor is outside the scope of this tutorial.
1. Connect to the publisher in SQL Server Management Studio, and then expand the
server node.
2. Right-click the Replication folder and select Configure Distribution:
REPLICATION FOR SQLSSERVER
Note
If you have connected to SQL Server by using localhost rather than the actual
server name, you'll be prompted with a warning that SQL Server cannot connect to
localhost. Select OK in the warning dialog box. In the Connect to Server dialog
box, change Server name from localhost to the name of your server. Then select
Connect.
3. On the Distributor page, select <'ServerName'> will act as its own Distributor;
SQL Server will create a distribution database and log. Then select Next.
REPLICATION FOR SQLSSERVER
4. If the SQL Server Agent is not running, on the SQL Server Agent Start page, select
Yes, configure the SQL Server Agent service to start automatically. Select
Next.
5. Enter the path \\<Publisher_Machine_Name>\repldata in the Snapshot folder box,
and then select Next. This path should match what you saw previously under
Network Path for your repldata properties folder after configuring your share
properties.
REPLICATION FOR SQLSSERVER
You might see the following error when configuring the distributor. It's an indication that
the account that was used to start the SQL Server Agent account is not an administrator on
the system. You'll either need to start the SQL Server Agent manually, grant those
permissions to the existing account, or modify which account the SQL Server Agent is
using.
If your SQL Server Management Studio instance is running with administrative rights, you
can start the SQL Agent manually from within SSMS:
REPLICATION FOR SQLSSERVER
Note
If the SQL Agent doesn't visibly start, right-click the SQL Server Agent in SSMS and
select Refresh. If it's still in the stopped state, start it manually from SQL Server
Configuration Manager.
3. On the User Mapping page, in the Users mapped to this login list, select both the
distribution and AdventureWorks2012 databases.
In the database role membership list, select the db_owner role for the login for both
databases.
5. Repeat steps 1-4 to create a login for the other local accounts (repl_distribution,
repl_logreader, and repl_merge). These logins must also be mapped to users who
are members of the db_owner fixed database role in the distribution and
AdventureWorks databases.