Introduction
In the earlier article (see TOC at the bottom), we explored how you can add the publisher and subscriber database in a high availability configuration using SQL Server Always On Availability Groups. It used a remote distributor for transactional replication.
Suppose the publisher and subscriber databases are on [SQLAG1\INST1] node, and failover happens to the node [SQLAG2\INST2]. In this case, the transactional replication works fine without any issues. It provided high resilience for the publisher and subscriber database.
What about the distribution database? Can we add it to the availability group? In this article, let’s explore the steps required for the distribution database AG.
Overview of the distribution database in the SQL Server Always On Availability Groups
We can add the replication distribution database in the availability group for high availability starting from SQL Server 2017 CU6 and SQL Server 2016 SP2-CU3. It requires special considerations for adding the distribution database.
- You must use a SQL listener for the distribution configuration
- It creates SQL jobs with the listener’s name
- It creates a new job to monitor the status of the distribution database in primary or secondary AG
- SQL Server automatically disables and enables the jobs based on the primary replica. For example, if the distribution database is on the SQLAG1, jobs are enabled on the SQLAG1 instance. In the case of DB failover, jobs got disabled on the SQLAG1 and enabled on the SQLAG2 instance
- The publisher and distributor database cannot exist in an instance
- We cannot use merge, Peer-To-Peer replication
- All replication databases (publisher, subscriber, and distributor) should be a minimum of SQL Server 2017 CU6 and SQL Server 2016 SP2-CU3
- We can use both synchronous and asynchronous data synchronization for the distribution database
- We cannot use the SSMS wizard for the distribution database AG configuration. It needs to set up using the scripts
- We cannot use an existing distribution database for the AG configuration. If the replication is already configured, we need to break the replication first and configure it using the scripts for AG configuration
- The secondary replica of the distribution database should allow read-only connections
- You should use the same domain account in all replica of the distribution database AG
Environmental details
In this article, we use the following environment.
Existing AG configuration:
We configure the distribution database in a new availability group on the following replicas.
- Primary Replica: SQLAG1\INST1
- Secondary Replica: SQLAG2\INST2
- Existing AG database: DBARepository
For this article, we use a standalone instance for the publisher and subscriber.
Publisher and Subscriber: SQLNode3\INST3
Therefore, the overall configuration in terms of the SQL Server replication topology is as below.:
- Publication Server: SQLNode3\INST3
- Subscription Server: SQLNode3\INST3
- Distribution Server: AG replica ( SQLAG1\INST1 & SQLAG2\INST2)
You can use the previous articles in the series to prepare a similar environment.
Steps to configure SQL Server replication distribution database in SQL Server Always On Availability Groups
Note: You can find the script attached at the bottom of the article.
#always on availability groups #installation #setup and configuration #replication #database