Configuring SQL Server replication for distribution databases

Configuring SQL Server replication for distribution databases

This article shows how to configure SQL Server replication for the database in SQL Server Always On Availability Group

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

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Database-level health detection in SQL Server Always On Availability Groups

This article gives an overview of SQL Server Always On Availability Group features. SQL Server Always On Availability Groups create a group of databases that fails over together in case the primary replica is unavailable.

Configure SQL Server replication for a database in SQL Server Always On

This article shows how to configure SQL Server replication for the database in SQL Server Always On Availability Groups

Configure Managed Service Accounts for SQL Server Always On Availability Groups

This article gives an overview of Configuring Managed Service Accounts for SQL Server Always On Availability Groups.

An overview of distributed SQL Server Always On Availability Groups

SQL Server 2016 provides a new feature Distributed Availability Group for disaster recovery purposes. It is a particular type of availability group that helps access the multiple failover clusters. In this article’s series, we configured a traditional Always On group. It has the following requirements.

SQL Server Always On Availability Group on the domain-independent Failover Cluster

This article configures SQL Server Always On Availability Groups on the domain independent Windows Failover Clusters. In the previous article, Deploy a domain-independent Windows Failover Cluster for SQL Server Always On Availability Groups, we learned the new capability in Windows Server 2016 to configure a domain-independent Windows failover cluster.