You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/database-engine/availability-groups/windows/replication-subscribers-and-always-on-availability-groups-sql-server.md
+19-16Lines changed: 19 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
---
2
-
title: Replication subscribers and Always On availability groups (SQL Server)
2
+
title: "Replication Subscribers and Always on Availability Groups (SQL Server)"
3
3
description: Learn what happens if an Always On availability group containing a database that is a replication subscriber fails over in SQL Server.
4
4
author: MashaMSFT
5
5
ms.author: mathoma
6
-
ms.reviewer: randolphwest
7
-
ms.date: 03/13/2023
6
+
ms.reviewer: mlandzic, randolphwest
7
+
ms.date: 11/28/2025
8
8
ms.service: sql
9
9
ms.subservice: availability-groups
10
-
ms.topic: conceptual
10
+
ms.topic: concept-article
11
11
helpviewer_keywords:
12
12
- "failover subscribers with AlwaysOn"
13
13
- "failover subscribers with Always On"
@@ -23,7 +23,7 @@ When an Always On availability group (AG) fails over, containing a database that
23
23
24
24
## What is supported
25
25
26
-
[!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] replication supports the automatic failover of the publisher and the automatic failover of transactional subscribers. Merge subscribers can be part of an AG, however manual actions are required to configure the new subscriber after a failover. AGs can't be combined with WebSync and SQL Server Compact scenarios.
26
+
[!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] replication supports the automatic failover of the publisher and the automatic failover of transactional subscribers. Merge subscribers can be part of an AG. However, manual actions are required to configure the new subscriber after a failover. AGs can't be combined with WebSync and SQL Server Compact scenarios.
27
27
28
28
## Create a transactional subscription in an availability group
29
29
@@ -33,18 +33,18 @@ For transactional replication, use the following steps to configure and fail ove
33
33
34
34
1. Add the subscriber's AG listener as a linked server to all nodes of the AG. This step ensures that all potential failover partners are aware of and can connect to the listener.
35
35
36
-
1. Using the script in the [Create a transactional replication push subscription](#create-a-transactional-replication-push-subscription) section, create the subscription using the name of the AG listener of the subscriber. After a failover, the listener name will always remain valid, whereas the actual server name of the subscriber will depend on the actual node that became the new primary.
36
+
1. Using the script in the [Create a transactional replication push subscription](#create-a-transactional-replication-push-subscription) section, create the subscription using the name of the AG listener of the subscriber. After a failover, the listener name always remains valid, whereas the actual server name of the subscriber depends on the actual node that became the new primary.
37
37
38
38
> [!NOTE]
39
-
> The subscription must be created by using a [!INCLUDE[tsql](../../../includes/tsql-md.md)] script and cannot be created using [!INCLUDE[ssManStudio](../../../includes/ssmanstudio-md.md)].
39
+
> You must use a [!INCLUDE[tsql](../../../includes/tsql-md.md)] script to create the subscription. You can't use [!INCLUDE[ssManStudio](../../../includes/ssmanstudio-md.md)].
40
40
41
41
1. To create a pull subscription:
42
42
43
43
1. Using the sample script in the [Create a transactional replication pull subscription](#create-a-transactional-replication-pull-subscription) section, create the subscription using the name of the AG listener of the subscriber.
44
44
45
45
1. After a failover, create the distribution agent job on the new primary replica using the `sp_addpullsubscription_agent` stored procedure.
46
46
47
-
When you create a pull subscription, with the subscription database in an AG, after every failover, it is recommended to disable the distribution agent job on the old primary replica and enable the job on the new primary replica.
47
+
When you create a pull subscription with the subscription database in an AG, after every failover, you should disable the distribution agent job on the old primary replica and enable the job on the new primary replica.
48
48
49
49
## Create a transactional replication push subscription
> When running [sp_addpullsubscription_agent](../../../relational-databases/system-stored-procedures/sp-addpullsubscription-agent-transact-sql.md) for a subscriber that is part of an AG, you must pass the `@Subscriber` parameter value to the stored procedure as the AG listener name. If you are running [!INCLUDE[sssql15-md](../../../includes/sssql16-md.md)] and earlier versions, or [!INCLUDE[sssql17-md](../../../includes/sssql17-md.md)] prior to CU 16, the stored procedure will not reference the AG listener name; it will be created with the subscriber server name on which the command is executed. To resolve this issue, manually update the `@Subscriber` parameter on the [Distribution Agent job](../../../relational-databases/replication/agents/replication-distribution-agent.md) with the AG listener name value.
99
+
### Availability group listener requirement
100
+
101
+
When you run [sp_addpullsubscription_agent](../../../relational-databases/system-stored-procedures/sp-addpullsubscription-agent-transact-sql.md) for a subscriber that's part of an AG, you must pass the `@subscriber` parameter value to the stored procedure as the AG listener name. If you run [!INCLUDE [sssql16-md](../../../includes/sssql16-md.md)] and earlier versions, or [!INCLUDE [sssql17-md](../../../includes/sssql17-md.md)] before CU 16, the stored procedure doesn't reference the AG listener name. It creates the subscription with the subscriber server name on which the command is executed. To resolve this issue, manually update the `@subscriber` parameter on the [Replication Distribution Agent](../../../relational-databases/replication/agents/replication-distribution-agent.md) with the AG listener name value.
102
+
103
+
If the subscriber AG listener uses a non-default port, providing port number as part of the AG listener name in the `@subscriber` parameter isn't supported on Windows. As a workaround, you can create an alias for the listener and port on publisher, distributor, and subscriber server using [Aliases (SQL Server Configuration Manager)](../../../tools/configuration-manager/aliases-sql-server-configuration-manager.md) or the [SQL Server Client Network Utility tool (cliconfg)](/previous-versions/windows/desktop/odbc/dn170508(v=vs.85)) for [!INCLUDE [sssql22-md](../../../includes/sssql22-md.md)] and later versions, and pass the alias as the `@subscriber` parameter value.
101
104
102
105
## Resume the merge agents after the availability group of the subscriber fails over
103
106
@@ -108,10 +111,10 @@ For merge replication, a replication administrator must manually reconfigure the
108
111
1. Recreate the subscription by creating a new subscription, beginning with a new snapshot.
109
112
110
113
> [!NOTE]
111
-
> The current process is inconvenient for merge replication subscribers, however the main scenario for merge replication is disconnected users (desktops, laptops, handset devices) which will not use AGs on the subscriber.
114
+
> This process is inconvenient for merge replication subscribers. However, the main scenario for merge replication is disconnected users (desktops, laptops, handset devices), which don't use AGs on the subscriber.
0 commit comments