Microsoft SQL Server Publication and Subscription
The publication and subscription function provided by Microsoft SQL Server uses the replication technology for data synchronization. This function makes it possible to split data read and write operations and synchronize offline and online data.
This section describes how to use SQL Server Management Studio (SSMS) to configure publication and subscription. You can create publications and subscriptions for RDS for SQL Server instances on the console. For details, see Creating a Publication.
Preparations
Environments
- Local environment: a local database running Microsoft SQL Server 2014 Standard Edition in Windows
- Online environment:
- One single DB instance with 2 vCPUs and 16 GB of memory running Microsoft SQL Server 2014 Standard Edition, bound with an EIP
- One primary/standby DB instance with 4 vCPUs and 8 GB of memory running Microsoft SQL Server 2014 Standard Edition, bound with an EIP
Environment Setup
- Publisher: maintains source data and distributes specific data to the distributor. In this example, use the local server as the publisher.
- Use SSMS to log in to the local database as user sa. Right-click the Replication folder and then click Configure Distribution. You can use your local server as the distributor or use another server as the distributor. Click Next.
- sa is the administrator account.
- The login account must have the sysadmin permission. Otherwise, publication and subscription cannot be configured.
- Specify a root snapshot folder and click Next.
Related agent permissions must be configured for the publication so that the agent account has the permissions to read from and write to the folder.
- Specify the names and directories of the distribution database and log files, and click Next.
- Specify the distributor for the publisher and then click Next.
- Click Finish to complete the configuration.
- Use SSMS to log in to the local database as user sa. Right-click the Replication folder and then click Configure Distribution. You can use your local server as the distributor or use another server as the distributor. Click Next.
- Configuring the agent account control file
- You need to add the agent account to the control property of the snapshot folder according to the folder directory. Otherwise, an error message will be displayed, indicating that the access is denied.
- Open the local SQL Server Configuration Manager, right-click the corresponding agent, choose Properties from the shortcut menu, and copy the account name.
- Return to the directory of the snapshot folder. Right-click the folder and choose Properties from the shortcut menu. In the displayed dialog box, choose Security > Edit > Add. Select the local path and agent account name, click OK, and select all permissions.
- Distributor: distributes data to specific subscribers. In this example, the distributor and publisher share the same server. Therefore, no extra configuration is required. For more information, see Configure Distribution at the official website.
- Subscriber: receives data from the distributor. Subscription includes push subscription and pull subscription.
- Push subscription: The publisher propagates changes to a subscriber without a request from the subscriber. Changes can be pushed to subscribers continuously or on a frequently recurring schedule.
- Pull subscription: The subscriber requests changes made at the publisher. The data is usually synchronized on demand or on a schedule rather than continuously. RDS for SQL Server instances do not support pull subscription. In this example, only push subscription can be configured.
Before the subscription, ensure that the RDS for SQL Server instance can be accessed from the local server.
Before configuring the local subscription, you need to configure the RDS instance information on the local server.
- Configure an alias name for the subscriber on the local server. The subscription service does not support IP address-based access. Therefore, you need to map the EIP of the RDS DB instance to an alias name. To obtain the alias name, log in to the RDS DB instance and run the following SQL statement:
select @@SERVERNAME
- After obtaining the alias name, open the local SQL Server Configuration Manager, select the native clients, right-click Aliases, and choose New Aliases from the shortcut menu.
- Enter related information and click OK.
Table 1 Parameter description Parameter
Description
Alias Name
Alias name configured in 1
Port No
Port number of the RDS instance
Server
EIP bound to the RDS instance
- In C:\Windows\System32\drivers\etc, open the host file and add a mapping:
Server_address MSSQL-177FFD84\MSSQL2014STD
Creating a Publication
- Create a publication.
Expand the Replication folder, and then right-click the Local Publications folder. Click New Publication.
- Select Transactional publication.
- Select a table as the publication object.
- Add the object to be filtered for personalized publication.
- Create a snapshot to replicate the current state of the table. You can also set up a snapshot agent to execute the plan.
- Configure the agent security. You need to set the login account to the local sa account.
- Configure the publication name and click Finish.
- Check whether the publication is created by using the replication monitor.
Creating a Subscription
- Right-click the publication for which you want to create one or more subscriptions, and then select New Subscriptions.
- Configure the required parameters and click Next.
- Select push subscription and click Next.
- Click Add Subscriber. Both the SQL Server engine and non-SQL Server engine can be used as subscribers. In this example, use the RDS for SQL Server instance as the subscriber.
- Select a database as the subscription object.
- Configure the connection to the subscriber.
- Use a database account that is valid for a long time to ensure the subscription validity. You can use the account for logging in to the RDS for SQL Server instance. Then, click OK.
- Check whether the subscription is created successfully.
- Move the cursor to the publication to view the subscription information.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot