共用方式為


CreateCluster method of the MSCluster_Cluster class

Creates a cluster.

Syntax

void CreateCluster(
  [in] string ClusterName,
  [in] string NodeNames[],
  [in] string IPAddresses[],
  [in] string SubnetMasks[],
  [in] uint32 AdministrativeAccessPoint
);

Parameters

ClusterName [in]

Cluster name.

NodeNames [in]

Node names that will form the cluster.

IPAddresses [in]

IP addresses that the cluster will use.

SubnetMasks [in]

IP address subnet masks or prefix lengths that the cluster will use.

AdministrativeAccessPoint [in]

The type of the cluster management point.

**Windows Server 2012 R2, Windows Server 2012, Windows Server 2008 R2 and Windows Server 2008: **

This parameter is not supported before Windows Server 2016.

None (0)

ActiveDirectoryAndDns (1)

Dns (2)

ActiveDirectory (3)

Return value

This method does not return a value.

Remarks

Due to delegation issues, by default a multinode cluster cannot be created with one call. To create a multinode cluster, first create the cluster using CreateCluster, wait 30 seconds, and then connect to each of the additional nodes and add them to the cluster using the AddNode method of the MSCluster_Cluster class.

To enable delegation, enable Trusted for delegation for the computer nodes in the directory and enable Kerberos authentication and impersonation level as Delegate when connecting to WMI (this has serious security implications). For more information, see Connecting to a 3rd Computer-Delegation.

Examples

' @Description: Creates a cluster that has static IP address using WMI Interface
' @Comments: No input from command line
' @Usage: Modify the parameters and run at CScript Prompt.

Option Explicit

' Global Vars

Dim szServerName
Dim szClusterName
Dim szUserName
Dim szPassword
Dim szArrIPAddrs
Dim szArrSubNetMasks
Dim szArrNodeNames
Dim szQuorum
Dim objSWbemServices


Main(WScript.Arguments)
Wscript.Quit

Function Main(WscriptArgs)
  ' Change the server name, user name, and password.

  szServerName     = "ClusterTest1"
  szClusterName    = "ClusterTest"
  szUserName       = NULL
  szPassword       = NULL
  szArrIPAddrs     = Array("10.10.0.1")
  szArrSubNetMasks = Array("255.255.255.0")
  szArrNodeNames   = Array("ClusterTest1")
  szQuorum         = NULL

  Set objSWbemServices = ClusWMI_ConnectServer()
  Call ClusWMI_CreateCluster(objSWbemServices)


End Function

Function ClusWMI_ConnectServer()

  Dim objSWbemLocator
  Dim objSWbemServices

  WScript.Echo "Connecting to WMI Namespace of " & szServerName

  Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
  Set objSWbemServices = objSWbemLocator.ConnectServer(szServerName,     _
                                                       "Root\MSCluster", _
                                                       szUserName,       _
                                                       szPassWord)
  'objSWbemServices.Security_.ImpersonationLevel = 4
  Set ClusWMI_ConnectServer = objSWbemServices

  WScript.Echo "Leaving ClusWMI_ConnectServer Method ..."

End Function

Function ClusWMI_CreateCluster(objSWbemServices_In)

  Dim objMSCluster
  Dim objInParams
  Dim objOutParams

  Set objMSCluster = objSWbemServices_In.Get("MSCluster_Cluster")
  Set objInParams = objMSCluster.Methods_("CreateCluster").InParameters.SpawnInstance_()

  objInParams.Properties_.Item("ClusterName") = szClusterName
  objInParams.Properties_.Item("IPAddresses") = szArrIPAddrs
  objInParams.Properties_.Item("SubnetMasks") = szArrSubNetMasks
  objInParams.Properties_.Item("NodeNames")   = szArrNodeNames
  objInParams.Properties_.Item("UserName")    = szUserName
  objInParams.Properties_.Item("Password")    = szPassword
  objInParams.Properties_.Item("Quorum")      = szQuorum

  Set objOutParams = objSWbemServices_In.ExecMethod("MSCluster_Cluster", _
                                                    "CreateCluster",     _
                                                    objInParams )



  WScript.Echo" Leaving CreateCluster Method..."

End Function

Requirements

Minimum supported client
None supported
Minimum supported server
Windows Server 2008
Namespace
Root\MSCluster
Header
Clusapi.h
MOF
ClusWmi.mof
DLL
ClusWMI.dll

See also

MSCluster_Cluster