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
An availability group listener is a virtual network name (VNN) that clients can connect to in order to access a database in a primary or secondary replica of an Always On availability group. A listener allows a client to connect to a replica without having to know the physical instance name of the SQL Server. Since the listener routes traffic, the client connection string does not need to be modified after a failover occurs.
27
+
An availability group listener is a virtual network name (VNN) that clients can connect to in order to access a database in a primary or secondary replica of an Always On availability group. A listener allows a client to connect to a replica without having to know the physical instance name of the SQL Server. Since the listener routes traffic, the client connection string doesn't need to be modified after a failover occurs.
28
28
29
29
An availability group listener consists of a Domain Name System (DNS) listener name, listener port designation, and one or more IP addresses. Only the TCP protocol is supported by availability group listener. The DNS name of the listener must be unique in the domain and in NetBIOS. When you create a listener, it becomes a resource in a cluster with an associated virtual network name (VNN), virtual IP (VIP), and availability group dependency. A client uses DNS to resolve the VNN into multiple IP addresses and then tries to connect to each address, until a connection request succeeds or until the connection requests time out.
30
30
@@ -48,13 +48,52 @@ This article provides an overview of an availability group listener. You can als
48
48
49
49
50
50
## <aname="SelectListenerPort"></a> Listener port
51
-
When configuring an availability group listener, you must designate a port. You can configure the default port to 1433 in order to allow for simplicity of the client connection strings. If using 1433, you do not need to designate a port number in a connection string. Also, since each availability group listener will have a separate virtual network name, each availability group listener configured on a single WSFC can be configured to reference the same default port of 1433.
52
-
53
-
You can also designate a non-standard listener port; however this means that you will also need to explicitly specify a target port in your connection string whenever connecting to the availability group listener. You will also need to open permission on the firewall for the non-standard port.
54
-
55
-
If you use the default port of 1433 for availability group listener VNNs, you will still need to ensure that no other services on the cluster node are using this port; otherwise this would cause a port conflict.
56
-
57
-
If one of the instances of SQL Server is already listening on TCP port 1433 via the instance listener and there are no other services (including additional instances of SQL Server) on the computer listening on port 1433, this will not cause a port conflict with the availability group listener. This is because the availability group listener can share the same TCP port inside the same service process. However multiple instances of SQL Server (side-by-side) should not be configured to listen on the same port.
51
+
When configuring an availability group listener, you must designate a port via SSMS. You can configure the default port to 1433 in order to allow for simplicity of the client connection strings. This means, that if you use 1433, you don't need to include a port number in a connection string of your application. Also, since each availability group listener will have a separate virtual network name, each availability group listener configured on a single WSFC can be configured to reference the same default port of 1433.
52
+
53
+
If you use the default port of 1433 for availability group listener VNNs, you'll still need to ensure that no other services on the cluster node are using this port; otherwise this would cause a port conflict.
54
+
55
+
If one of the instances of SQL Server is already listening on TCP port 1433 via the instance listener and there are no other services (including additional instances of SQL Server) on the computer listening on port 1433, this won't cause a port conflict with the availability group listener. This is because the availability group listener can share the same TCP port inside the same process. However multiple instances of SQL Server (side-by-side) must not be configured to listen on the same port because one of them will fail to listen for connections.
56
+
57
+
You can also designate a non-standard availability group listener port. However, you also need to explicitly use the target port in your application connection string when connecting to a listener. You also need to open permission on the firewall for this port.
58
+
59
+
You can connect to the listener using the name and port (if not 1433). The port can be either the listener port or the underlying SQL Server port that it's configured to listen on.
60
+
61
+
The following examples demonstrate some of the functionality of the listener:
62
+
63
+
**Set up:**
64
+
- IP that SQL Server is listening on: 192.168.20.2
65
+
- Port that SQL Server is listening on: 50254
66
+
- Listener IP that was configured: 192.168.20.15
67
+
- Listener name was configured: aglistener19
68
+
- Listener port that was configured: 50123
69
+
70
+
1. Connect to the listener via IP address and port. This connection is successful.
71
+
72
+
```console
73
+
sqlcmd -S 192.168.20.15,50123
74
+
1>
75
+
```
76
+
77
+
1. Connect to the listener by name only, no port. This connection will fail because a non-default port was used. You must specify that port.
78
+
79
+
```console
80
+
sqlcmd -S aglistener19
81
+
```
82
+
83
+
1. Connect to the listener by listener name and configured port. This connection is successful.
84
+
85
+
```console
86
+
sqlcmd -S aglistener19,50123
87
+
1>
88
+
```
89
+
90
+
91
+
1. Finally, connect to the listener and the SQL Server port. Notice that in this case you're using the port SQL Server is listening on, not the listener port. This connection also succeeds.
92
+
93
+
```console
94
+
sqlcmd -S aglistener19,50254
95
+
1>
96
+
```
58
97
59
98
60
99
## <a name="CCBehaviorOnFailover"></a> Behavior of client connections on failover
Copy file name to clipboardExpand all lines: docs/database-engine/availability-groups/windows/troubleshoot-always-on-availability-groups-configuration-sql-server.md
+71-18Lines changed: 71 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,10 +27,11 @@ ms.author: mathoma
27
27
28
28
|Section|Description|
29
29
|-------------|-----------------|
30
-
|[Always On Availability Groups Is Not Enabled](#IsHadrEnabled)|If an instance of [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] is not enabled for [!INCLUDE[ssHADR](../../../includes/sshadr-md.md)], the instance doesn't support availability group creation and cannot host any availability replicas.|
30
+
|[Always On Availability Groups Isn't Enabled](#IsHadrEnabled)|If an instance of [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] is not enabled for [!INCLUDE[ssHADR](../../../includes/sshadr-md.md)], the instance doesn't support availability group creation and can't host any availability replicas.|
31
31
|[Accounts](#Accounts)|Discusses requirements for correctly configuring the accounts under which [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] is running.|
32
32
|[Endpoints](#Endpoints)|Discusses how to diagnose issues with the database mirroring endpoint of a server instance.|
33
33
|[Network access](#NetworkAccess)|Documents the requirement that each server instance that is hosting an availability replica must be able to access the port of each of the other server instances over TCP.|
34
+
|[Listener](#Listener)|Documents how to establish the IP address and port of the listener and make sure it is running and listening for incoming connections|
34
35
|[Endpoint Access (SQL Server Error 1418)](#Msg1418)|Contains information about this [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] error message.|
35
36
|[Join Database Fails (SQL Server Error 35250)](#JoinDbFails)|Discusses the possible causes and resolution of a failure to join secondary databases to an availability group because the connection to the primary replica isn't active.|
36
37
|[Read-Only Routing is Not Working Correctly](#ROR)||
@@ -108,7 +109,7 @@ For more information, see [Enable and Disable Always On Availability Groups (
108
109
GO
109
110
```
110
111
111
-
3. For [!INCLUDE[ssHADR](../../../includes/sshadr-md.md)] setup issues that are difficult to explain, we recommend that you inspect each server instance to determine whether it is listening on the correct ports.
112
+
3. For [!INCLUDE[ssHADR](../../../includes/sshadr-md.md)] setup issues that are difficult to explain, we recommend that you inspect each server instance to determine whether it's listening on the correct ports.
112
113
113
114
4. Make sure that the endpoints are started (STATE=STARTED). On each server instance, use the following [!INCLUDE[tsql](../../../includes/tsql-md.md)] statement:
114
115
@@ -155,17 +156,20 @@ For more information, see [Enable and Disable Always On Availability Groups (
155
156
select endpoint_url from sys.availability_replicas
156
157
```
157
158
158
-
Next, compare the endpoint_url output to the server name (Netbiosor FQDN).
159
-
To query the Netbios and FQDN, run the following commandin a Command Prompton the replica locally:
159
+
Next, compare the endpoint_url output to the server name (NetBIOS name or FQDN).
160
+
To query the server name, run the following commands in a PowerShell on the replica locally:
@@ -174,11 +178,16 @@ For more information, see [Enable and Disable Always On Availability Groups (
174
178
## <a name="NetworkAccess"></a> Network Access
175
179
Each server instance that is hosting an availability replica must be able to access the port of each of the other server instance over TCP. This is especially important if the server instances are in different domains that don't trust each other (untrusted domains). Check if you can connect to the endpoints by following these steps:
176
180
177
-
- Use Telnet to validate connectivity. Here are examples of commands you can use:
181
+
- Use Test-NetConnection (equivalent to Telnet) to validate connectivity. Here are examples of commands you can use:
- Capture the output from Get-NetTCPConnection cmdlet (equivalent of NETSTAT -a) and verify the status is a LISTENING or ESTABLISHED on the IP:Port for the endpoint specified
204
+
205
+
```PowerShell
206
+
Get-NetTCPConnection
207
+
```
208
+
209
+
210
+
## <a name="Listener"></a> Listener
192
211
193
-
- Capture a NETSTAT -a output and verify the status is a LISTENING or ESTABLISHED on the IP:Port for the endpoint specified
212
+
For correct configuration of an Availability Group listener follow "[Configure a listener for an Always On availability group](create-or-configure-an-availability-group-listener-sql-server.md)"
194
213
195
-
```dos
196
-
netstat -a
214
+
1. Once the listener is configured you can validate the IP address and port it is listening on by using the following query:
215
+
216
+
```PowerShell
217
+
$server_name = $env:computername #replace this with your sql instance "server\instance"
218
+
219
+
sqlcmd -E -S$server_name -Q"SELECT dns_name AS AG_listener_name, port, ip_configuration_string_from_cluster
220
+
FROM sys.availability_group_listeners"
221
+
```
197
222
223
+
1. You can also find the listener information together with the SQL Server ports using this query:
224
+
225
+
```PowerShell
226
+
$server_name = $env:computername #replace this with your sql instance "server\instance"
WHERE ip_address not in ('127.0.0.1', '::1') and type <> 2")
231
+
```
232
+
233
+
1. If you need to establish connectivity to the listener and suspect a port is blocked, you can perform a test using the PowerShell Test-NetConnection cmdlet (equivalent to telnet).
## <a name="Msg1418"></a> Endpoint Access (SQL Server Error 1418)
200
-
This [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] message indicates that the server network address specified in the endpoint URL cannot be reached or doesn't exist, and it suggests that you verify the network address name and reissue the command.
253
+
This [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] message indicates that the server network address specified in the endpoint URL can't be reached or doesn't exist, and it suggests that you verify the network address name and reissue the command.
201
254
202
255
## <a name="JoinDbFails"></a> Join Database Fails (SQL Server Error 35250)
203
256
This section discusses the possible causes and resolution of a failure to join secondary databases to the availability group because the connection to the primary replica isn't active. This is the full error message:
@@ -300,7 +353,7 @@ For **detailed** step-by-step instructions, refer to Engine error [MSSQLSERVER_3
300
353
>[!NOTE]
301
354
> If you are running [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] on Azure VM, you must take additional configuration steps. Ensure that the network security group (NSG) of each replica VM allows traffic to the endpoint port and the DNN port, if you are using DNN listener. If you are using VNN listener, you must ensure the [load balancer is configured correctly](/azure/azure-sql/virtual-machines/windows/availability-group-load-balancer-portal-configure).
302
355
303
-
7. Ensure that the READ_ONLY_ROUTING_URL (TCP://system-address:port) contains the correct fully-qualified domain name (FQDN) and port number. See:
356
+
7. Ensure that the READ_ONLY_ROUTING_URL (TCP://system-address:port) contains the correct fullyqualified domain name (FQDN) and port number. See:
304
357
- [Calculating read_only_routing_url for Always On](/archive/blogs/mattn/calculating-read_only_routing_url-for-alwayson)
0 commit comments