Defining a New Resource TypeThis chapter tells you how to define a new resource type:It also tells you how to test the results in .
To define a new resource type, you must have the following information:resource typeinformation required
to define a new resource typeName of the resource type. The name can consist of alphanumeric
characters and any of the following:- (hyphen)
_ (underscore)
/
.
:
"
=
@
, The name cannot contain a space, an unprintable character, or any of
the following characters: *
?
\
#Name of the cluster to which the resource type will apply.
If the resource type is to be restricted to a specific node,
you must know the node name.Order of performing the action scripts for resources of this
type in relation to resources of other types:Resources are started in the increasing order of this value
Resources are stopped in the decreasing order of this value
Ensure that the number you choose for a new resource type permits the
resource types on which it depends to be started before it is started, or
stopped after it is stopped, as appropriate. shows the conventions used for order
ranges. The values available for customer use are 201-400 and 701-999.
Order RangesRangeReservation1-100SGI-provided basic system resource
types, such as MAC_address101-200SGI-provided system plug-ins that can
be started before IP_address201-400User-defined resource types that can
be started before IP_address401-500SGI-provided basic system resource
types, such as IP_address501-700SGI-provided system plug-ins that must
be started after IP_address701-999User-defined resource types that must
be started after IP_address
resource typeorder
rangesorder
ranges for resource types shows the order numbers of the resource
types provided with the release or available as plug-ins from SGI.
Resource Type Order NumbersOrder NumberResource Type10MAC_address20volume30filesystem201NFS401IP_address411statd502Samba
Restart mode, which can be one of the following values:resource typerestart mode
restart mode
0 = Do not restart on monitoring failures1 = Restart a fixed number of timesNumber of local restarts (when restart mode is 1).Location of the executable script. This is always
/usr/lib/failsafe/resource_types/resource_type_tnameusr/lib/failsafe/resource_types
directory.Monitoring interval, which is the time period (in milliseconds)
between successive executions of the monitor action script;
this is only valid for the monitor action script.Starting time for monitoring. When the resource group is made
online in a cluster node, Linux FailSafe will start monitoring the resources
after the specified time period (in milliseconds).Action scripts to be defined for this resource type. You must
specify scripts for start, stop,
exclusive, and monitor, although the
monitor script may contain only a return-success function if you
wish. If you specify 1 for the restart mode, you must specify a
restart script.Type-specific attributes to be defined for this resource type.
The action scripts use this information to start, stop, and monitor a resource
of this resource type. For example, NFS requires the following resource keys:
export-info which takes a value that defines
the export options for the file system. These options are used in the
kexportfs command. For example:export-info = rw,wsync,anon=rootfilesystem which takes a value that defines
the raw file system. This name is used as input to the mount
command. For example:filesystem = /dev/xlv/xlv_objectUsing the GUIYou can use the FailSafe Manager graphical user interface (GUI) to define
a new resource type and to define the dependencies for a given type. For details
about the GUI, see the Linux FailSafe Administrator's Guide.
For convenience, , contains information about
starting the GUI.Define a New Resource TypeTo define a new resource type using the GUI, select the following task:resource typeGUI useResources & Resource Types => Define a Resource TypeThe GUI will prompt you for required and optional information. Online
help is provided for each item.The following figures show this process for a new resource type called
newresourcetype.Select Define a New ResourceSpecify the Name of the New Resource TypeSpecify Settings for Required ActionsChange Settings for Optional ActionsSet Type-specific AttributesDefine DependenciesTo define the dependencies for a given type use the following task:
Add/Remove Dependencies for a Resource Type shows an example of adding two dependencies
(filesystem and NFS) to the
newresourcetype resource type.Add DependenciesUsing cluster_mgr InteractivelyThe following steps show the use of cluster_mgr interactively
to define a resource type called newresourcetype. Note
that you can have multiple resource types. For example, if you want to have
some IP addresses that allow local restart (restart mode = 0) and some that
do not (restart mode = 1), you can copy the IP_address
type to a new type named IP_address2 and change just that
value in the IP_address2. cmgr commandresource typecluster_mgr
use
cluster_mgr commandA resource type name cannot contain a space, an unprintable character,
or any of the following characters: *
?
\
#Log in as root.Execute the cluster_mgr command using the
-p option to prompt you for information (the command name can be
abbreviated to cmgr): # /usr/lib/failsafe/bin/cluster_mgr -p
Welcome to Linux FailSafe Cluster Manager Command-Line Interface
cmgr>Use the set subcommand to specify the default
cluster used for cluster_mgr operations. In this example,
we use a cluster named test:cmgr> set cluster testIf you prefer, you can specify the cluster name as needed with each
subcommand.Use the define resource_type subcommand.
By default, the resource type will apply across the cluster; if you wish to
limit the resource type to a specific node, enter the node name when prompted.
If you wish to enable restart mode, enter 1 when prompted.The following example only shows the prompts and answers for two action
scripts (start and stop) for a new resource
type namednewresourcetype.cmgr> define resource_type newresourcetype
(Enter "cancel" at any time to abort)
Node[optional]?
Order ? 300
Restart Mode ? (0)
DEFINE RESOURCE TYPE OPTIONS
1) Add Action Script.
2) Remove Action Script.
3) Add Type Specific Attribute.
4) Remove Type Specific Attribute.
5) Add Dependency.
6) Remove Dependency.
7) Show Current Information.
8) Cancel. (Aborts command)
9) Done. (Exits and runs command)
Enter option:1
No current resource type actions
Action name ? start
Executable Time? 40000
Monitoring Interval? 0
Start Monitoring Time? 0
1) Add Action Script.
2) Remove Action Script.
3) Add Type Specific Attribute.
4) Remove Type Specific Attribute.
5) Add Dependency.
6) Remove Dependency.
7) Show Current Information.
8) Cancel. (Aborts command)
9) Done. (Exits and runs command)
Enter option:1
Current resource type actions:
Action - 1: start
Action name stop
Executable Time? 40000
Monitoring Interval? 0
Start Monitoring Time? 0
1) Add Action Script.
2) Remove Action Script.
3) Add Type Specific Attribute.
4) Remove Type Specific Attribute.
5) Add Dependency.
6) Remove Dependency.
7) Show Current Information.
8) Cancel. (Aborts command)
9) Done. (Exits and runs command)
Enter option:3
No current type specific attributes
Type Specific Attribute ? integer-att
Datatype ? integer
Default value[optional] ? 33
1) Add Action Script.
2) Remove Action Script.
3) Add Type Specific Attribute.
4) Remove Type Specific Attribute.
5) Add Dependency.
6) Remove Dependency.
7) Show Current Information.
8) Cancel. (Aborts command)
9) Done. (Exits and runs command)
Enter option:3
Current type specific attributes:
Type Specific Attribute - 1: export-point
Type Specific Attribute ? string-att
Datatype ? string
Default value[optional] ? rw
1) Add Action Script.
2) Remove Action Script.
3) Add Type Specific Attribute.
4) Remove Type Specific Attribute.
5) Add Dependency.
6) Remove Dependency.
7) Show Current Information.
8) Cancel. (Aborts command)
9) Done. (Exits and runs command)
Enter option:5
No current resource type dependencies
Dependency name ? filesystem
1) Add Action Script.
2) Remove Action Script.
3) Add Type Specific Attribute.
4) Remove Type Specific Attribute.
5) Add Dependency.
6) Remove Dependency.
7) Show Current Information.
8) Cancel. (Aborts command)
9) Done. (Exits and runs command)
Enter option:7
Current resource type actions:
Action - 1: start
Action - 2: stop
Current type specific attributes:
Type Specific Attribute - 1: integer-att
Type Specific Attribute - 2: string-att
No current resource type dependencies
Resource dependencies to be added:
Resource dependency - 1: filesystem
1) Add Action Script.
2) Remove Action Script.
3) Add Type Specific Attribute.
4) Remove Type Specific Attribute.
5) Add Dependency.
6) Remove Dependency.
7) Show Current Information.
8) Cancel. (Aborts command)
9) Done. (Exits and runs command)
Enter option:9
Successfully defined resource_type newresourcetype
cmgr> show resource_types in cluster test
NFS
template
newresourcetype
statd
MAC_address
IP_address
filesystem
volume
cmgr> exit
# Using cluster_mgr With a ScriptYou can write a script that contains all of the information required
to define a resource type and supply it to cluster_mgr
by using the -f option:
resource typescript usecluster_mgr -f scriptnameOr, you could include the following as the first line of the script
and then execute the script itself:#!/usr/lib/failsafe/bin/cluster_mgr -fIf any line of the script fails, cluster_mgr will
exit. You can choose to ignore the failure and continue the process by using
the -i option, as follows:#!/usr/lib/failsafe/bin/cluster_mgr -ifIf you include -i when using a cluster_mgr command
line as the first line of the script, you must use this exact syntax (that
is, -if)./usr/lib/failsafe/cmgr-templates/cmgr-create-resource_type
directoryA template script for creating
a new resource type is located in /usr/lib/failsafe/cmgr-templates/cmgr-create-resource_type
.resource typescript templatestemplatesresource type script definition Each line of the script must be a valid cluster_mgr
line, a comment line (starting with #), or a blank line.You must include a done command line to finish a
multi-level command. If you concatenate information from multiple template
scripts to prepare your cluster configuration, you must remove the
quit at the end of each template script.For example, you could use the following script to define the same
newresourcetype resource type defined interactively in the previous
section:# newresourcetype.script: Script to define the "newresourcetype" resource type
set cluster test
define resource_type newresourcetype
set order to 300
set restart_mode to 0
add action start
set exec_time to 40000
set monitor_interval to 0
set monitor_time to 0
done
add action stop
set exec_time to 40000
set monitor_interval to 0
set monitor_time to 0
done
add type_attribute integer-att
set data_type to integer
set default_value to 33
done
add type_attribute string-att
set data_type to string
set default_value to rw
done
add dependency filesystem
done
quit When you execute the cluster_mgr -f command line
with this script, you will see the following output:# /usr/lib/failsafe/bin/cluster_mgr -f newresourcetype.script
Successfully defined resource_type newresourcetype
# To verify that the resource type was defined, enter the following:# /usr/lib/failsafe/bin/cluster_mgr -c "show resource_types in cluster test"
NFS
template
newresourcetype
statd
MAC_address
IP_address
filesystem
volumeTesting a New Resource TypeAfter adding a new resource type, you should test it as follows:Define a resource group that contains resources of the new
type. Ensure that the group contains all of the resources on which the new
resource type depends.Bring the resource group online in the cluster using
cluster_mgr or the GUI.For example, using cluster_mgr:cmgr>
admin online resource_group new_rg in cluster test_clusterCheck the status of the resource group using cluster_mgr
or GUI after a few minutes.For example:cmgr> show status of resource_group new_rg in cluster test_cluster
If the resource group has been made online successfully, you
will see output similar to the following: State: Online
Error: No error
Owner: node1If there are resource group errors, do the following:Check the srmd logs ( /var/log/failsafe/srmd_
nodename) on the node on which the resource group
is onlineSearch for the string ERROR in the log
file. There should be an error message about a resource in the resource group.
The message also provides information about the action script that failed.
For example: Wed Nov 3 04:20:10.135 <E ha_srmd srm 12127:1 sa_process_tasks.c:627>
CI_FAILURE, ERROR: Action (exclusive) for resource (10.0.2.45) of type
(IP_address) failed with status (failed)
exclusive script failed for the resource 10.0.2.45 of resource type
IP_address. The status "failed"
indicates that the script returned an error.Check the script logs (/var/log/failsafe/script_
nodename on the same node) for IP_address
exclusive script errors.After the fixing the problems in the action script, perform
an offline_force operation to clear the error. For example:
cmgr> admin offline_force resource_group new_rg in cluster test_cluster