SQL server database synchronization (publish and subscribe) [solution]

SQL server database synchronization (publish and subscribe) [solution]


Note: When connecting to the database, pay attention to whether the connected database is on the selected server! [Insert picture description here](https://img-blog.csdnimg.cn/38812acbb640420b89ba666dd016adb8.png)

1. Let the local firewall pass through

Open port 1433 in the local firewalls of the publisher and subscriber server
. Refer to [Operation Method] Windows Firewall to add inbound and outbound rules.

2. Create a shared folder

2.1 Create a shared folder on the publisher server, which is used to provide a medium for database information synchronization

insert image description here

2.2 Set sharing permissions, add everyone, and the permissions are read

insert image description here

3. Publisher Settings Publish

3.1 Start SQL Server Agent

insert image description here

3.2 Setting up a new publication

insert image description here

3.3 Note: If there is a path option, enter the network path of the shared folder (right-click the shared folder, properties, share, network path)

insert image description here

3.4 Select the database to publish

insert image description here

3.5 Select snapshot release here, and other release types can be explained below for self-viewing

insert image description here

3.6 Check the data table to be published, or just select a part of the table

insert image description here

3.7 Here you can filter the data table fields as needed

insert image description here

3.8 Check all

insert image description here

3.9 Click here to modify the agent running time and interval

insert image description here

3.10 Click Security Settings

insert image description here

3.11 Select as shown in the figure, the sa password is the sa password of the publishing server

insert image description here

3.12 Enter the release name, here I entered DB123

insert image description here

3.13 Click Finish to generate a local release

insert image description here

4. Subscriber Settings Subscription

4.1 Create a new subscription database

insert image description here

insert image description here
insert image description here

4.2 Find the publisher

insert image description here

4.3 Connect data, the database connected here is the database of the publisher

insert image description here

4.4 Select the published database

insert image description here

4.5 Choosing a Proxy Location

Select here to affect the agent management location, select the distribution server to manage all on the publisher server, select the subscriber server to manage subscriptions on the subscriber server, and manage publishing on the publisher server
insert image description here

4.6 Select the subscription database (the previously created database)

insert image description here

4.7 Setting Distribution Agent Security

insert image description here

4.8 According to the following selection, the sa password is the sa password of the publishing server

insert image description here
Then all the next steps until complete

4.9 View synchronization status

Right click on Replication, select Start Replication Monitor
insert image description here

4.10 Click "Add Publisher"

insert image description here

4.11 Click Add, choose to add SAQ Server publishing server, enter the sa password of the publishing server, and click OK

insert image description here

4.12 Open the upper left corner to view the database synchronization status

As shown in the figure, DB123 is successful and running normally, but DBPublisher is running abnormally, you can report an error for troubleshooting
insert image description here

Guess you like

Origin blog.csdn.net/qq_30054403/article/details/130287083