问题描述

在SQLServer2016上创建可用性组失败,错误显示如下:

Failed to bring availability group 'availability_group' online. The operation timed out.
Verify that the local Windows Server Failover Clustering (WSFC) node is online.
Then verify that the availability group resource exists in the WSFC cluster.
If the problem persists, you might need to drop the availability group and create it again.

原因

导出集群日志(PowerShell)

mkdir d:\trace
Get-ClusterLog -Destination d:\trace

其中错误信息如下

ODBC Error: [42000] [Microsoft][SQL Server Native Client 11.0][SQL Server]The user does not have permission to perform this action. (297)
Failed to run diagnostics command. See previous log for error message

如果在SQL Server登录时丢失[NT AUTHORITY\SYSTEM]帐户,或者该帐户缺乏创建高可用性组所需的权限,就会发生此问题。

解决方案

创建NT AUTHORITY\SYSTEM账户

USE [master]
GO
CREATE LOGIN [NT AUTHORITY\SYSTEM] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO

添加相关权限

GRANT ALTER ANY AVAILABILITY GROUP TO [NT AUTHORITY\SYSTEM]
GO
GRANT CONNECT SQL TO [NT AUTHORITY\SYSTEM]
GO
GRANT VIEW SERVER STATE TO [NT AUTHORITY\SYSTEM]
GO

Tips:Cannot create a high-availability group in Microsoft SQL Server 2012