0

Using Powershell, how can I find out if my server has NUMA enabled and how many CPUs are assigned to each NUMA node?

Update:

I found out here that the microsoft.sqlserver.management.smo.server object object has an affinityinfo field. However, that field doesn't exist in my server object in Powershell when I create it (SQL Server 2005 on Windows XP).

Update:

It appears that the affinityinfo field only exists in SQL Server 2008 R2 and later.

4

2 回答 2

1

有可用的 API 可以为您获取此信息,但它们是非托管的,这意味着它们不容易从 PowerShell (.NET) 调用。为了直接调用这些,您必须使用Add-Typecmdlet 将 C# 代码编译为内存中的程序集,然后您可以从中实例化或调用静态方法。我的博客上有一个这样的例子。

编写 C# 是一个棘手的部分,因为有很多看起来不友好的代码与之相关,请查看这个示例。如果您熟悉 C#,则可能可以根据需要进行调整。如果没有,Mark 有一个名为Coreinfo的工具,它看起来可以为您提供所需的信息。它实际上调用与链接的 p/invoke 代码相同的非托管 API ( GetLogicalProcessorInformation )。您可以从 PowerShell 中调用它并处理其 STDOUT。

于 2012-01-12T21:21:43.240 回答
0

我认为 Windows 7 和 Windows Server 2008 R2 中用于处理超过 64 个逻辑处理器的本机 OS API 在 .NET 中不可用,您可以查看.NET Support for More than 64 Processors。这个人曾经为 OS API 编写一个 .NET 包装器,您可能在 PowerShell 中使用它。

于 2012-01-12T10:31:44.767 回答