The Generic Script resource type allows us to achieve high availability for applications that can be controlled through scriptable interfaces. If you have an application that can be started, stopped, and monitored through a script, you can run the application as a scripted resource. Note that you have to implement the Generic Script resource DLL entry points in the script file. A scripted resource is an instance of the Generic Script resource type under the control of a script. The scripts run in the Windows Scripting Host.
The Generic Script resource DLL implements a Resource Object for each instance of a generic script resource. Resource Objects have methods and properties that your script can use to accomplish several tasks such as identifying the resource, logging information about the resource, and manipulating private properties of the resource. For more information about the resource object, visit http://msdn.microsoft.com/en-us/library/aa372270(VS.85).aspx .
In this section, we will cover how to create and configure a generic script resource using the following methods:
1. High Availability Wizard
2. PowerShell CMDlets
3. Cluster.exe command-line tool (To be deprecated after Windows Server 2008 R2)
We will be using a VB script as an example. The example script can be found here: http://msdn.microsoft.com/en-us/library/aa372844(VS.85).aspx .
Before creating a generic script resource, please review the following checklist:
I have a 2-node cluster running Windows Server 2008 R2. Cluster name is A1C1F4X64.
Name of my cluster nodes are:
Below is a partial screenshot of Failover Cluster Manager.
Now I will walk you through the High Availability wizard of Failover Cluster Manager to create a generic script resource. Below are the steps:
1. Launch Failover Cluster Manager from the Start Menu.
2. Connect to the cluster. Right click on Services and applications , and click on Configure a Service or Application…
3. The High Availability Wizard appears. After reading the information presented on Before You Begin page, click Next .
4. On Select Service or Application page, select Generic Script and click Next .
5. On Generic Script Info page, provide the path to the script file. Click Next .
Client Access Point
page, we will be providing input for the network name and IP addresses that clients will be using when accessing our highly available generic script.
I am choosing a network name (A1C1F4X64G Scr ) and a static IP address suitable for my network configuration.
Click Next .
page, you have an option to choose a disk for the generic script. If the generic script needs a disk resource, you can select a disk.
My example script writes data to a file, so the script needs access to a shared disk. I am choosing Cluster Disk 2 as my disk resource. After making the storage selection, click Next .
8. On the Confirmation page, verify that the information is correct. If you need to make modifications, you can use the Previous button to go back to the previous pages in the wizard and modify the information.
Click Next .
9. Wizard should successfully create the generic script resource and bring the resource online. The Summary page appears.
10. On Summary page, you can click on View Report… button. This will show you detailed report of what actions were taken to create the Generic Script resource.
The report can also be located under %SystemRoot%\Cluster\Reports directory for later viewing. Click Finish .
11. Locate the newly created item (A1C1F4X64G Scr ) under Services and applications . This is the container (also known as group) for the generic script resource.
The above image shows that group A1C1F4X64GScr is hosted on node A1C1F4X64N2. The name of the generic script resource is “GenericScriptTemplate Script”.
I will now show you how to use PowerShell CMDlets to create a generic script resource. The CMDlets that we need to achieve this are: Get-Cluster and Add-ClusterGenericScriptRole .
If we are running PowerShell on a machine that is not part of the cluster, we have to retrieve the cluster object first using the Get-Cluster CMDlet. Once we retrieve the cluster object, the object can then be passed to Add-ClusterGenericScriptRole CMDlet. This is needed to specify the cluster where the resource will be created.
If we are running PowerShell on a clustered node, Get-Cluster CMDlet may be omitted and Add-ClusterGenericScriptRole can be used directly. In this case cluster object will be retrieved from the local node (i.e. the node where the command is executing):
PS C:\Windows\wttbin> Get-Cluster A1C1F4X64 | Add-ClusterGenericScriptRole -ScriptFilePath C:\windows\wttbin\GenericScriptTemplate.vbs -Name A1C1F4X64GSCR -StaticAddress 172.24.11.96
Report file location: C:\Users\Daud\AppData\Local\Temp\tmp2B58.tmp.mht
Name OwnerNode State
---- --------- -----
A1C1F4X64GSCR a1c1f4x64n2 Online
Cluster.exe is another command line tool that can be used to administer a cluster. Note that this tool is in the phase of being deprecated. This tool will coexist with PowerShell in Windows Server 2008 R2. However, Cluster.exe will no longer be shipped after Windows Server 2008 R2.
Below is a sample script that creates and onlines a generic script resource.
REM Store cluster name in a variable
REM Create a group and online it
cluster %ClusterName% group GenScrGroup /create
cluster %ClusterName% group GenScrGroup /on
REM Create a IP address resource, set required properties, and online it
cluster %ClusterName% res GenScrIP /create /group:GenScrGroup /type:"IP Address"
cluster %ClusterName% res GenScrIP /priv address=172.24.11.96 SubnetMask=255.255.255.0
cluster %ClusterName% res GenScrIP /on
REM Create a network name, set properties, set dependency on the IP resource, and online it
cluster %ClusterName% res GenSvcNN /create /group:GenScrGroup /type:"Network name"
cluster %ClusterName% res GenSvcNN /priv Name=%ClusterName%-NN
cluster %ClusterName% res GenSvcNN /setdep:"[GenScrIP]"
cluster %ClusterName% res GenSvcNN /on
REM Create a generic script resource, set the properties, and online it
cluster %ClusterName% res GenScrRes /create /group:GenScrGroup /type:"Generic Script"
cluster %ClusterName% res GenScrRes /prop RestartAction="0"
cluster %ClusterName% res GenScrRes /priv ScriptFilepath="C:\windows\wttbin\GenericScriptTemplate.vbs"
cluster %ClusterName% res GenScrRes /on
The script does the following:
1. Creates and onlines a group called GenScrGroup .
2. Creates an IP address resource called GenScrIP in group GenScrGroup . Sets Address and SubnetMask properties of the resource. Brings the IP resource online.
3. Creates a network name resource called GenScrNN . Sets the Name property of the network name resource, sets the dependency of the network name to the IP resource, and brings the network name online.
4. Creates the generic application resource called GenScrRes , sets the properties, and brings the resource online.
· Generic Script Resource Type - http://technet.microsoft.com/en-us/library/cc737409.aspx
· Using The Generic Script Resource Type - http://msdn.microsoft.com/en-us/library/aa373089(VS.85).aspx
· Scripting Entry Points - http://msdn.microsoft.com/en-us/library/aa372846(VS.85).aspx
· Scripted Resource Example - http://msdn.microsoft.com/en-us/library/aa372844(VS.85).aspx
· Checklist: Installing a Generic Script resource - http://technet.microsoft.com/en-us/library/cc736970.aspx
· Resource Object - http://msdn.microsoft.com/en-us/library/aa372270(VS.85).aspx
· Windows Clustering - http://msdn.microsoft.com/en-us/library/aa373130(VS.85).aspx
· Generic Application blog: http://blogs.msdn.com/clustering/archive/2009/04/10/9542115.aspx
· Generic Service blog: http://blogs.msdn.com/clustering/archive/2009/06/09/9712609.aspx
Software Development Engineer in Test
Clustering & High Availability
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.