当遇到 MSSQL AlwaysOn 可用性组(Availability Group)中的所有副本均不健康的情况时(MSSQL AG '副本名称': All replicas unhealthy),这通常意味着可用性组无法正常工作,数据同步和故障转移功能可能受到影响。以下是一些可能的原因及相应的排查步骤和解决方法:
1. 检查副本状态
首先,确认每个副本的具体状态。您可以使用以下 T-SQL 查询来检查可用性组和副本的状态:
-- 查看可用性组的状态
SELECT ag.name AS AvailabilityGroupName,ar.replica_server_name AS ReplicaServerName,ars.role_desc AS Role,ars.operational_state_desc AS OperationalState,ars.connected_state_desc AS ConnectedState,ars.health_state_desc AS HealthState
FROM sys.availability_groups ag
JOIN sys.availability_replicas ar ON ag.group_id = ar.group_id
LEFT JOIN sys.dm_hadr_availability_replica_states ars ON ar.replica_id = ars.rep