Skip to content

Commit bc52036

Browse files
MladjoArwestMSFT
authored andcommitted
Update replication subscriber documentation for AG
1 parent eb5f1eb commit bc52036

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

docs/database-engine/availability-groups/windows/replication-subscribers-and-always-on-availability-groups-sql-server.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
title: Replication subscribers and Always On availability groups (SQL Server)
2+
title: "Replication Subscribers and Always on Availability Groups (SQL Server)"
33
description: Learn what happens if an Always On availability group containing a database that is a replication subscriber fails over in SQL Server.
44
author: MashaMSFT
55
ms.author: mathoma
6-
ms.reviewer: randolphwest
7-
ms.date: 03/13/2023
6+
ms.reviewer: mlandzic, randolphwest
7+
ms.date: 11/28/2025
88
ms.service: sql
99
ms.subservice: availability-groups
10-
ms.topic: conceptual
10+
ms.topic: concept-article
1111
helpviewer_keywords:
1212
- "failover subscribers with AlwaysOn"
1313
- "failover subscribers with Always On"
@@ -23,7 +23,7 @@ When an Always On availability group (AG) fails over, containing a database that
2323

2424
## What is supported
2525

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.
2727

2828
## Create a transactional subscription in an availability group
2929

@@ -33,18 +33,18 @@ For transactional replication, use the following steps to configure and fail ove
3333

3434
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.
3535

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.
3737

3838
> [!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)].
4040
4141
1. To create a pull subscription:
4242

4343
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.
4444

4545
1. After a failover, create the distribution agent job on the new primary replica using the `sp_addpullsubscription_agent` stored procedure.
4646

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.
4848

4949
## Create a transactional replication push subscription
5050

@@ -62,7 +62,7 @@ EXEC sp_addsubscription @publication = N'<publication name>',
6262
@update_mode = N'read only',
6363
@subscriber_type = 0;
6464
GO
65-
65+
6666
EXEC sp_addpushsubscription_agent @publication = N'<publication name>',
6767
@subscriber = N'<AG listener name>',
6868
@subscriber_db = N'<subscriber database name>',
@@ -86,7 +86,7 @@ EXEC sp_addpullsubscription @publisher = N'<publisher name>',
8686
GO
8787

8888
EXEC sp_addpullsubscription_agent @publisher = N'<publisher name>',
89-
@subscriber = N'<AG listener name>',
89+
@subscriber = N'<AG listener name or alias>',
9090
@distributor = N'<distributor AG listener name>', -- this parameter should only be used if the distribution database is part of an AG.
9191
@publisher_db = N'<publisher database name>',
9292
@publication = N'<publication name>',
@@ -96,8 +96,11 @@ EXEC sp_addpullsubscription_agent @publisher = N'<publisher name>',
9696
GO
9797
```
9898

99-
> [!NOTE]
100-
> 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.
101104

102105
## Resume the merge agents after the availability group of the subscriber fails over
103106

@@ -108,10 +111,10 @@ For merge replication, a replication administrator must manually reconfigure the
108111
1. Recreate the subscription by creating a new subscription, beginning with a new snapshot.
109112

110113
> [!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.
112115
113-
## See also
116+
## Related content
114117

115-
- [Replication subscribers](../../../relational-databases/replication/subscribers.md)
118+
- [Subscribers](../../../relational-databases/replication/subscribers.md)
116119
- [Replication tutorials](../../../relational-databases/replication/replication-tutorials.md)
117-
- [Distribution database](../../../relational-databases/replication/distribution-database.md)
120+
- [Distribution Database](../../../relational-databases/replication/distribution-database.md)

0 commit comments

Comments
 (0)