简体   繁体   English

如何确定故障转移群集中的活动节点

[英]How to determine the active node in a failover cluster

We need a way to determine from code which node of an application cluster is currently active.我们需要一种方法来从代码中确定应用程序集群的哪个节点当前处于活动状态。 Is there a way to do this using C#?有没有办法使用 C# 做到这一点?

You will be coding against the MSCluster_Resource Class: "The MSCluster_Resource class is a dynamic WMI class that represents a cluster resource." 您将对MSCluster_Resource类进行编码:“MSCluster_Resource类是表示集群资源的动态WMI类。”

The API documentation can be found here: http://msdn.microsoft.com/en-us/library/aa371464(VS.85).aspx API文档可以在这里找到: http//msdn.microsoft.com/en-us/library/aa371464(VS.85).aspx

More details on your answer can be found here: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/60589403-dd9a-4196-8d95-154a4a931e19/ 有关您的答案的更多详细信息,请访问: http//social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/60589403-dd9a-4196-8d95-154a4a931e19/

This isn't C# code, it's PowerShell.这不是 C# 代码,而是 PowerShell。 So, it's not an answer, but I needed a PowerShell solution to get the nodes in general (not necessarily the active node) and this question came up in my Google search.所以,这不是答案,但我需要一个 PowerShell 解决方案来获取一般节点(不一定是活动节点),这个问题出现在我的 Google 搜索中。 IMO, the PowerShell FailoverClusters module is rather poorly written, so I have to revert to (mostly) non-PowerShell objects (like WMI) to get it done right. IMO,PowerShell FailoverClusters 模块编写得相当糟糕,所以我必须恢复到(大部分)非 PowerShell 对象(如 WMI)才能正确完成。

$Clusters=Get-ADComputer -Server "<specific domain controller (optional)" -LDAPFilter "(servicePrincipalName=*MSClusterVirtualServer/*)" -SearchBase "OU=Servers,DC=<domain name>,DC=com" | Select-Object -ExpandProperty DNSHostName
$ClusterNodes=$Clusters | ForEach-Object { Get-WMIObject -Namespace "root\MSCluster" -ComputerName $_ -Query "SELECT Name FROM MSCluster_Node" -EnableAllPrivileges } | Select-Object -ExpandProperty Name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQL Server 2014群集故障转移实例,如何在故障转移时重新连接? - SQL Server 2014 Cluster Failover Instance, how to reconnect on failover? 如何升级在 Windows 故障转移群集上运行的通用应用程序 - How to upgrade a generic application running on a windows failover cluster SignalR主动/被动故障转移设置 - SignalR active/passive failover setup 如何确定tabControl中的活动控件 - How to determine the active control within a tabControl 如何确定Windows域中的计算机是否处于“活动”状态 - How to determine if a computer in my Windows Domain is “active” 如何在NGUI中确定活动子项并获取数据 - How to determine active child and get data in NGUI 获取.Net中的故障转移群集角色的主机名 - get hostname of failover cluster role in .Net Windows 故障转移集群 API 仍然有效吗? - Windows Failover Cluster API still Valid? 在Azure上将Active Directory设置为故障转移实例 - Setting up Active directory on Azure as a failover instance 如何防止Windows 2012 R2故障转移群集在使用自动化C#应用程序时破坏角色? - How to prevent Windows 2012 R2 Failover Cluster from destroying a role while using an automated C# application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM