Skip to content

Commit e895181

Browse files
authored
Merge pull request #23144 from prmadhes-msft/patch-1
Adding commands for troubleshooting
2 parents b8cba87 + 2162022 commit e895181

1 file changed

Lines changed: 96 additions & 16 deletions

File tree

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

Lines changed: 96 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
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
ms.custom: "seodec18"
5-
ms.date: "05/17/2016"
5+
ms.date: "07/28/2022"
66
ms.prod: sql
77
ms.reviewer: ""
88
ms.technology: availability-groups
@@ -15,7 +15,9 @@ ms.assetid: 1a2162d3-54fb-4356-b349-effbdc15a5a4
1515
author: MashaMSFT
1616
ms.author: mathoma
1717
---
18+
1819
# Availability replica is disconnected within an Always On availability group
20+
1921
[!INCLUDE [SQL Server](../../../includes/applies-to-version/sqlserver.md)]
2022

2123
## Introduction
@@ -26,28 +28,106 @@ ms.author: mathoma
2628
- **Facet**: Availability replica
2729

2830
## Description
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.
31+
32+
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.
3033

31-
## Possible Causes
32-
The secondary replica is not connected to the primary replica. The connected state is DISCONNECTED. This issue can be caused by the following:
34+
## Possible Causes
35+
36+
The secondary replica isn't connected to the primary replica. The connected state is DISCONNECTED. This issue can be caused by the following:
3337

34-
- The connection port might be in conflict with another application.
38+
- The connection port might be in conflict with another application.
3539

36-
- The encryption type or algorithm is mismatched.
40+
- The encryption type or algorithm is mismatched.
3741

38-
- The connection endpoint has been deleted or has not been started.
39-
40-
- The transport is disconnected.
42+
- The connection endpoint has been deleted or hasn't been started.
4143

44+
- There are network/connectivity issues or Ports are blocked at the firewall.
45+
46+
- 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)
47+
4248
## Possible Solutions
43-
Following are possible solutions for this issue:
44-
45-
- Check the database mirroring endpoint configuration for the instances of the primary and secondary replica and update the mismatched configuration.
49+
50+
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.
51+
52+
The following are possible solutions for this issue:
53+
54+
- The connection port might be in conflict with another application.
55+
56+
Run the following commands to diagnose port issue:
57+
58+
```PowerShell
59+
$server_name = "server_instance" #replace with your instance
60+
Sqlcmd -S $server_name -E -Q "SELECT type_desc, port FROM sys.tcp_endpoints WHERE type_desc = 'DATABASE_MIRRORING'; "
61+
```
62+
The above command will return the port number that you have to use in below command.
63+
64+
```PowerShell
65+
$port = "5022"
66+
Get-NetTCPConnection -LocalPort $port
67+
Get-Process -Id (Get-NetTCPConnection -LocalPort $port).OwningProcess |Select-Object Name, ProductVersion, Path, Id
68+
```
69+
70+
- The encryption type or algorithm is mismatched.
71+
72+
Run this on both servers and compare the encryption and make sure both are same:
73+
74+
```PowerShell
75+
$server_name = "server_instance" #replace with your instance
76+
sqlcmd -S $server_name -E -Q "SELECT name, state_desc, encryption_algorithm_desc, protocol_desc, type_desc FROM sys.database_mirroring_endpoints"
77+
```
78+
79+
- The connection endpoint has been deleted or hasn't been started.
80+
81+
Run the following command if the mirroring endpoint exits and is started.
82+
83+
```PowerShell
84+
$server_name = "…."
85+
Sqlcmd -S $server_name -E -Q "SELECT name, state_desc, encryption_algorithm_desc, protocol_desc, type_desc FROM sys.database_mirroring_endpoints"
86+
```
87+
88+
Run the below command if you suspect that endpoint is not responding to connections or is not running.
4689

47-
- Check if the port is conflicting, and if so, change the port number.
90+
```SQL
91+
ALTER ENDPOINT hadr_endpoint
92+
STATE = stopped
93+
94+
ALTER ENDPOINT hadr_endpoint
95+
STATE = started
96+
```
97+
98+
- There are network /connectivity issues or Ports are blocked at the firewall
99+
100+
Use the following commands to test connectivity in both directions from Node1 to Node2 and Node2 to Node1:
101+
102+
```PowerShell
103+
$computer = $env:computername
104+
$port = "5022" # replace with the port from your database_mirroring_endpoints.
105+
Test-NetConnection -ComputerName $computer -Port $port
106+
```
107+
108+
- 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)
109+
110+
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:
111+
112+
1. Select **Start** > **Windows PowerShell** > right-click the icon.
113+
1. Select **More** > **Run as Different User** > **Use a different account**.
114+
1. Type the service account name and password.
115+
1. After Windows PowerShell opens, type the following command to verify you've logged in with the service account:
116+
117+
```PowerShell
118+
whoami
119+
```
120+
121+
1. Then you can test the connection to the remote node. For example:
122+
123+
```PowerShell
124+
$computer = "remote_node" # Replace with Naode name as per your environment.
125+
$port = "5022" # Replace with the port from your database_mirroring_endpoints.
126+
Test-NetConnection -ComputerName $computer -Port 5022
127+
```
48128
49-
## See Also
50-
[Overview of Always On Availability Groups (SQL Server)](../../../database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server.md)
51-
[Use the Always On Dashboard (SQL Server Management Studio)](../../../database-engine/availability-groups/windows/use-the-always-on-dashboard-sql-server-management-studio.md)
129+
## See also
130+
- [Overview of Always On Availability Groups (SQL Server)](../../../database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server.md)
131+
- [Use the Always On Dashboard (SQL Server Management Studio)](../../../database-engine/availability-groups/windows/use-the-always-on-dashboard-sql-server-management-studio.md)
52132
53133

0 commit comments

Comments
 (0)