SQL server database synchronization (publish and subscribe) [solution]
- 1. Let the local firewall pass through
- 2. Create a shared folder
- 3. Publisher Settings Publish
-
- 3.1 Start SQL Server Agent
- 3.2 Setting up a new publication
- 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)
- 3.4 Select the database to publish
- 3.5 Select snapshot release here, and other release types can be explained below for self-viewing
- 3.6 Check the data table to be published, or just select a part of the table
- 3.7 Here you can filter the data table fields as needed
- 3.8 Check all
- 3.9 Click here to modify the agent running time and interval
- 3.10 Click Security Settings
- 3.11 Select as shown in the figure, the sa password is the sa password of the publishing server
- 3.12 Enter the release name, here I entered DB123
- 3.13 Click Finish to generate a local release
- 4. Subscriber Settings Subscription
-
- 4.1 Create a new subscription database
- 4.2 Find the publisher
- 4.3 Connect data, the database connected here is the database of the publisher
- 4.4 Select the published database
- 4.5 Choosing a Proxy Location
- 4.6 Select the subscription database (the previously created database)
- 4.7 Setting Distribution Agent Security
- 4.8 According to the following selection, the sa password is the sa password of the publishing server
- 4.9 View synchronization status
- 4.10 Click "Add Publisher"
- 4.11 Click Add, choose to add SAQ Server publishing server, enter the sa password of the publishing server, and click OK
- 4.12 Open the upper left corner to view the database synchronization status
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
2.2 Set sharing permissions, add everyone, and the permissions are read
3. Publisher Settings Publish
3.1 Start SQL Server Agent
3.2 Setting up a new publication
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)
3.4 Select the database to publish
3.5 Select snapshot release here, and other release types can be explained below for self-viewing
3.6 Check the data table to be published, or just select a part of the table
3.7 Here you can filter the data table fields as needed
3.8 Check all
3.9 Click here to modify the agent running time and interval
3.10 Click Security Settings
3.11 Select as shown in the figure, the sa password is the sa password of the publishing server
3.12 Enter the release name, here I entered DB123
3.13 Click Finish to generate a local release
4. Subscriber Settings Subscription
4.1 Create a new subscription database
4.2 Find the publisher
4.3 Connect data, the database connected here is the database of the publisher
4.4 Select the published database
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
4.6 Select the subscription database (the previously created database)
4.7 Setting Distribution Agent Security
4.8 According to the following selection, the sa password is the sa password of the publishing server
Then all the next steps until complete
4.9 View synchronization status
Right click on Replication, select Start Replication Monitor
4.10 Click "Add Publisher"
4.11 Click Add, choose to add SAQ Server publishing server, enter the sa password of the publishing server, and click OK
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