SQL Server 故障转移集群 - 确定活动节点
有没有办法以编程方式确定 SQL Server 故障转移群集中的哪个节点是活动节点?或者至少判断当前机器是否是主动节点?
我有一个 Windows 程序,它在故障转移群集中的两个物理节点上运行,但根据它是否在活动节点上运行,其操作应该有所不同。 部分原因是该程序不应该在非活动节点和活动节点上同时运行。
(我读过一些关于让程序集群感知的内容,但这对于这个简单的场景来说似乎太过分了。)
Is there a way to programmatically determine which node in a SQL Server failover cluster is the active node? Or at least determine whether the current machine is the active node?
I have a Windows program which runs on both physical nodes in a failover cluster, but that should operate differently depending on whether it is running on the active node. Part of the reason is that this program should not run simultaneously on the inactive and the active node.
(I've read a bit about making the program cluster aware, but that seems heavily overkill for this simple scenario.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 SQL Server:
您还可以通过 Microsoft.SqlServer.Management.Smo 命名空间访问它,如下所示 此处。
From SQL Server:
You can also access it through the Microsoft.SqlServer.Management.Smo Namespace as shown here.
您可以这样检查:
1。检查可用性组状态:
*请记住更改 AvailabilityGroupName
或
2。阻止在辅助设备上执行作业:
或
3。检查辅助设备上的写入可用性:
或
4。对于 SQL2014 及更高版本:
You can check like that:
1. Check Availability Group Status:
*Remember to change AvailabilityGroupName
or
2. prevent executing job on secondary:
or
3. check write availability on secondary:
or
4. for SQL2014 and newer: