[英]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.