Skip to content

Commit a52cdaa

Browse files
committed
Address PR 9770
1 parent 181daca commit a52cdaa

1 file changed

Lines changed: 105 additions & 107 deletions

File tree

docs/database-engine/availability-groups/windows/availability-replica-is-disconnected.md

Lines changed: 105 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ title: "Availability replica is disconnected in an availability group"
33
description: "Identify possible causes for why a replica is disconnected within an Always On availability group."
44
author: MashaMSFT
55
ms.author: mathoma
6-
ms.date: "07/28/2022"
6+
ms.reviewer: randolphwest
7+
ms.date: 05/08/2024
78
ms.service: sql
89
ms.subservice: availability-groups
910
ms.topic: troubleshooting
@@ -16,119 +17,116 @@ helpviewer_keywords:
1617
# Availability replica is disconnected within an Always On availability group
1718

1819
[!INCLUDE [SQL Server](../../../includes/applies-to-version/sqlserver.md)]
19-
20-
## Introduction
21-
20+
21+
## Introduction
22+
2223
- **Policy Name**: Availability Replica Connection State
23-
- **Issue**: Availability replica is disconnected.
24+
- **Issue**: Availability replica is disconnected
2425
- **Category**: **Critical**
25-
- **Facet**: Availability replica
26-
27-
## Description
28-
29-
This policy checks the connection state between availability replicas. The policy is in an unhealthy state when the connection state of the availability replica is DISCONNECTED. The policy is otherwise in a healthy state.
30-
31-
## Possible Causes
32-
33-
The secondary replica isn't connected to the primary replica. The connected state is DISCONNECTED. This issue can be caused by the following:
34-
35-
- The connection port might be in conflict with another application.
36-
37-
- The encryption type or algorithm is mismatched.
38-
39-
- The connection endpoint has been deleted or hasn't been started.
40-
41-
- There are network/connectivity issues or Ports are blocked at the firewall.
42-
43-
- Service/startup account isn't a domain user and isn't able to connect to the DC and to the remote node and port (for example, 5022)
44-
45-
## Possible Solutions
46-
47-
Check the database mirroring endpoint configuration for the instances of the primary and secondary replica and update the mismatched configuration. Also, check if the port is conflicting, and if so, change the port number.
48-
49-
The following are possible solutions for this issue:
50-
51-
- The connection port might be in conflict with another application.
52-
53-
Run the following commands to diagnose port issue:
54-
55-
```PowerShell
56-
$server_name = "server_instance" #replace with your SQL Server instance
57-
Sqlcmd -S $server_name -E -Q "SELECT type_desc, port FROM sys.tcp_endpoints WHERE type_desc = 'DATABASE_MIRRORING'; "
58-
```
59-
The above command will return the port number that you have to use in below command.
60-
61-
```PowerShell
62-
$port = "5022"
63-
Get-NetTCPConnection -LocalPort $port
64-
Get-Process -Id (Get-NetTCPConnection -LocalPort $port).OwningProcess |Select-Object Name, ProductVersion, Path, Id
65-
```
26+
- **Facet**: Availability replica
6627

67-
- The encryption type or algorithm is mismatched.
28+
## Description
6829

69-
Run this on both servers and compare the encryption and make sure both are same:
30+
This policy checks the connection state between availability replicas. The policy is in an unhealthy state when the connection state of the availability replica is `DISCONNECTED`. The policy is otherwise in a healthy state.
7031

71-
```PowerShell
72-
$server_name = "server_instance" #replace with your SQL Server instance
73-
sqlcmd -S $server_name -E -Q "SELECT name, state_desc, encryption_algorithm_desc, protocol_desc, type_desc FROM sys.database_mirroring_endpoints"
74-
```
32+
## Possible causes
33+
34+
The secondary replica isn't connected to the primary replica. The connected state is `DISCONNECTED`. This issue can be caused by one of the following reasons:
35+
36+
- [The connection port might be in conflict with another application](#the-connection-port-might-be-in-conflict-with-another-application).
37+
- [The encryption type or algorithm is mismatched](#the-encryption-type-or-algorithm-is-mismatched).
38+
- [The connection endpoint was deleted or isn't started](#the-connection-endpoint-was-deleted-or-isnt-started).
39+
- [There are network/connectivity issues or Ports are blocked at the firewall](#network-or-connectivity-issues-or-ports-are-blocked-at-the-firewall).
40+
- [Service/startup account isn't a domain user and isn't able to connect to the DC and to the remote node and port (for example, 5022)](#account-isnt-a-domain-user-and-cant-connect-to-the-dc-and-to-the-remote-node).
41+
42+
## Possible solutions
43+
44+
Check the database mirroring endpoint configuration for the instances of the primary and secondary replica and update the mismatched configuration. Also, check if the port is conflicting, and if so, change the port number.
45+
46+
The following are possible solutions for this issue:
47+
48+
#### The connection port might be in conflict with another application
49+
50+
Run the following commands to diagnose port issues:
51+
52+
```powershell
53+
$server_name = "server_instance" #replace with your SQL Server instance
54+
sqlcmd -S $server_name -E -Q "SELECT type_desc, port FROM sys.tcp_endpoints WHERE type_desc = 'DATABASE_MIRRORING'; "
55+
```
56+
57+
The previous command returns the port number that you have to use in the following command.
58+
59+
```powershell
60+
$port = "5022"
61+
Get-NetTCPConnection -LocalPort $port
62+
Get-Process -Id (Get-NetTCPConnection -LocalPort $port).OwningProcess | Select-Object Name, ProductVersion, Path, Id
63+
```
64+
65+
#### The encryption type or algorithm is mismatched
66+
67+
Run this command on both servers and compare the encryption and make sure both are the same.
68+
69+
```powershell
70+
$server_name = "server_instance" #replace with your SQL Server instance
71+
sqlcmd -S $server_name -E -Q "SELECT name, state_desc, encryption_algorithm_desc, protocol_desc, type_desc FROM sys.database_mirroring_endpoints"
72+
```
7573

76-
- The connection endpoint has been deleted or hasn't been started.
77-
78-
Run the following command if the mirroring endpoint exits and is started.
79-
80-
```PowerShell
81-
$server_name = "server_instance" #replace with your SQL Server instance
82-
Sqlcmd -S $server_name -E -Q "SELECT name, state_desc, encryption_algorithm_desc, protocol_desc, type_desc FROM sys.database_mirroring_endpoints"
74+
#### The connection endpoint was deleted or isn't started
75+
76+
Run the following command if the mirroring endpoint exits and is started.
77+
78+
```powershell
79+
$server_name = "server_instance" #replace with your SQL Server instance
80+
sqlcmd -S $server_name -E -Q "SELECT name, state_desc, encryption_algorithm_desc, protocol_desc, type_desc FROM sys.database_mirroring_endpoints"
81+
```
82+
83+
Run the following command if you suspect that endpoint isn't responding to connections, or isn't running.
84+
85+
```powershell
86+
$server_name = "server_instance" #use your SQL Server instance here
87+
$server_name = "hadr_endpoint" #replace with your endpoint name
88+
sqlcmd -S $server_name -E -Q "ALTER ENDPOINT hadr_endpoint STATE = stopped"
89+
sqlcmd -S $server_name -E -Q "ALTER ENDPOINT hadr_endpoint STATE = started"
90+
```
91+
92+
> [!WARNING]
93+
> Running the command with `STATE = stopped` will stop your endpoint and temporarily interrupt Always On traffic flow.
94+
95+
#### Network or connectivity issues, or ports are blocked at the firewall
96+
97+
Use the following commands to test connectivity in both directions from `Node1` to `Node2` and `Node2` to `Node1`:
98+
99+
```powershell
100+
$computer = "remote_node" # replace with node name in your environment
101+
$port = "5022" # replace with the port from your database_mirroring_endpoints
102+
Test-NetConnection -ComputerName $computer -Port $port
103+
```
104+
105+
#### Account isn't a domain user and can't connect to the DC, and to the remote node
106+
107+
To test whether the service account can connect to the remote node, follow these steps. The steps assume that you aren't logged in with the service account.
108+
109+
1. Select **Start** > **Windows PowerShell** > right-click the icon.
110+
111+
1. Select **More** > **Run as Different User** > **Use a different account**.
112+
113+
1. Type the service account name and password.
114+
115+
1. After Windows PowerShell opens, type the following command to verify that you signed in with the service account:
116+
117+
```powershell
118+
whoami
83119
```
84120

85-
Run the below command if you suspect that endpoint is not responding to connections or is not running.
86-
87-
88-
```PowerShell
89-
$server_name = "server_instance" #use your SQL Server instance here
90-
$server_name = "hadr_endpoint" #replace with your endpoint name
91-
Sqlcmd -S $server_name -E -Q "ALTER ENDPOINT hadr_endpoint STATE = stopped"
92-
Sqlcmd -S $server_name -E -Q "ALTER ENDPOINT hadr_endpoint STATE = started"
93-
```
94-
>[!WARNING]
95-
>Running the command with `STATE = stopped` will stop your endpoint and temporarily interrupt Always On traffic flow.
96-
97-
98-
99-
- There are network /connectivity issues or Ports are blocked at the firewall
100-
101-
Use the following commands to test connectivity in both directions from Node1 to Node2 and Node2 to Node1:
102-
103-
```PowerShell
104-
$computer = "remote_node" # Replace with node name in your environment.
105-
$port = "5022" # replace with the port from your database_mirroring_endpoints.
106-
Test-NetConnection -ComputerName $computer -Port $port
121+
1. Then you can test the connection to the remote node, as in the following example.
122+
123+
```powershell
124+
$computer = "remote_node" # replace with node name in your environment
125+
$port = "5022" # replace with the port from your database_mirroring_endpoints
126+
Test-NetConnection -ComputerName $computer -Port $port
107127
```
108128

109-
- Service/startup account is not a domain user and is not able to connect to the DC and to the remote node and port (for example, 5022)
110-
111-
To test whether the service account can connect to the remote node, follow these steps. The steps assume that you are not logged in with the service account:
112-
113-
1. Select **Start** > **Windows PowerShell** > right-click the icon.
114-
1. Select **More** > **Run as Different User** > **Use a different account**.
115-
1. Type the service account name and password.
116-
1. After Windows PowerShell opens, type the following command to verify you've logged in with the service account:
117-
118-
```PowerShell
119-
whoami
120-
```
121-
122-
1. Then you can test the connection to the remote node. For example:
123-
124-
```PowerShell
125-
$computer = "remote_node" # Replace with node name in your environment.
126-
$port = "5022" # Replace with the port from your database_mirroring_endpoints.
127-
Test-NetConnection -ComputerName $computer -Port 5022
128-
```
129-
130-
## See also
131-
- [Overview of Always On Availability Groups (SQL Server)](../../../database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server.md)
132-
- [Use the Always On Dashboard (SQL Server Management Studio)](../../../database-engine/availability-groups/windows/use-the-always-on-dashboard-sql-server-management-studio.md)
133-
134-
129+
## Related content
130+
131+
- [What is an Always On availability group?](overview-of-always-on-availability-groups-sql-server.md)
132+
- [Use the Always On Availability Group dashboard (SQL Server Management Studio)](use-the-always-on-dashboard-sql-server-management-studio.md)

0 commit comments

Comments
 (0)